开发者

hiding index.php and all the variables from url

开发者 https://www.devze.com 2023-04-11 20:46 出处:网络
I\'am using a mod_rewrite to get the virtual subdomain as a variable in my site and would like to add a rule to hide the index.php and all the variables in the url

I'am using a mod_rewrite to get the virtual subdomain as a variable in my site and would like to add a rule to hide the index.php and all the variables in the url but can't get it to work. Any suggestions pl开发者_运维百科ease? This is my actual .htaccess:

RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.mysite\.com$
RewriteCond %{HTTP_HOST} ^(.*)\.mysite\.com$
RewriteRule ^$ /index.php?member=%1 [P,L]


Your best bet is probably to send in a support ticket and have the domain wildcarded.

.htaccess seems perfect.

Detail Description:

You will need to ask hosting company to add "wild-card" DNS set up to forward all subdomains to Web root directory. For example *.domain.com to www.domain.com. They can do this by adding A entry in DNS setting

HTACCESS Code

<IfModule mod_rewrite.c>

# Redirect to user blog (with any trailing path)
RewriteCond %{HTTP_HOST} !^www. [NC]
RewriteCond %{HTTP_HOST} ^([a-z0-9]).example.com(.*)$ [NC]
RewriteRule ^(.*)$ /index.php?member=$1 [R=301,L]

## Otherwise, force www;
RewriteCond %{HTTP_HOST} ^example.com$ [NC]
RewriteRule ^(.*)$ http://www.example.com/ [R=301,L]

</IfModule>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号