Jump to content

[PHP/APACHE] mod_rewrite


lopez86100

Recommended Posts

I am quite a newbie with mod rewrite.

I've created .htaccess file in my root directory. I've anabled mod_rewrite and wildcard.

 

Now I'm trying to write one rule but it is to difficult for me. I'm trying for 5 days and nothing :P.

 

The rule has to "replace" url for example : http://www.my.very.long.subdomain.domain.com/file_name.php   into   http://www.domain.com/my.very.long.subdomain/file_name.php

I don't want to redirect it but just to show file_name.php which is located in real directory (the directory name in this case is my.very.long.subdomain), , it's wildcard so it doesn't work as normal subdomain.

 

The rule can't rewrite url if there is index.php after slash (e.g. http://www.my.very.long.subdomain.domain.com/index.php),

in this case it can not be rewritten.

 

So, I've made something like this but it doesn't work for me.

 

------------------

.htaccess file

------------------

 

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !^/?index\.php$

RewriteCond %{HTTP_HOST} ^www\..*\.domain\.com/.*\.php/?

RewriteRule ^w?w?w?\.?(.*)\.domain\.com/(.*)\.php$ domain.com/$1/$2.php

 

Please somebody help me :):P

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.