开发者

htaccess not working properly

开发者 https://www.devze.com 2023-04-12 02:09 出处:网络
My current htaccess looks like this: RewriteEngine On RewriteCond %{HTTP_HOST} ^(www\\.)?site\\.com [NC]

My current htaccess looks like this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?site\.com [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/\.]+)/?$ index.php?page=$1
RewriteRule ^([^/\.]+)/([^/\.]+)?$ index.php?page=$1&subsectie=$2
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)?$ index.php?page=$1&subsectie=$2&subid=$3

I've edited the htaccess file. It should only use this htaccess for the main domain and not for subdomains, however subdomains still use this htaccess.

Anyone with more experience than me could point me out in the right direction? Thanks in advance.

Edit: Here is my current (and working) htaccess:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^([^/\.]+)/([^/\.]+)?$ in开发者_StackOverflowdex.php?page=$1&subsectie=$2
RewriteCond %{HTTP_HOST} ^(www\.)?domain\.com$ [NC]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)?$ index.php?page=$1&subsectie=$2&subid=$3


Try this:

RewriteEngine On

# first, remove redirect to www by default if no subdomain
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule (.*) http://www.domain.com/$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^([^/\.]+)/?$ index.php?page=$1 [NC,L]
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&subsectie=$2 [NC,L]
RewriteCond %{HTTP_HOST} ^www\.domain\.com [NC]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?page=$1&subsectie=$2&subid=$3 [NC,L]
0

精彩评论

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

关注公众号