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
https://forums.phpfreaks.com/topic/39822-phpapache-mod_rewrite/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.