English 中文(简体)
不能正常工作
原标题:htaccess not working properly

我的access切期望:

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. 它只应在主要领域,而不是在子域使用这一通道,但次域仍使用这一通道。

具有比我更丰富经验的任何人,都可以在正确方向指出? 提前感谢。

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 ^([^/.]+)/([^/.]+)?$ index.php?page=$1&subsectie=$2
RewriteCond %{HTTP_HOST} ^(www.)?domain.com$ [NC]
RewriteRule ^([^/.]+)/([^/.]+)/([^/.]+)?$ index.php?page=$1&subsectie=$2&subid=$3
最佳回答

为此:

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]
问题回答

暂无回答




相关问题
Ignore symlinks in clean URL s in .htaccess

Example URL: example.com/user /user is both a symlinked directory and a valid URL to content on my site. I user Horde Routes to request the content and all requests to the site go through index.php. ...

.htaccess File Options -Indexes on Subdirectories

I have the following .htaccess line, simple no indexes on root. Options -Indexes What do we add so it propagates to any sub directory instead of having to create one file for each? One .htaccess on ...

Mod Rewrite ignoring -d

After a day or two, I am still fighting with Mod Rewrite. It seems that 60% of my development time is spent battling the server. My current URL structure is such that all http://example.com/xyz and ...

ErrorDocument 404 Not Sending Referrer Information: PHP

I m using a standard htaccess ErrorDocument 404 to redirect users to a new page. In order to customize the 404, I need to know their referrer information (from the page they Tried to visit). $...

Find all htaccess files on server [closed]

I m looking for a Linux command to go through all the directories on my server and find all .htaccess files. The output would be a list of all those files with full path, creation/modification date ...

301 Redirect Help with Dynamic URL s and Multiple Id s

I just did a redesign for www.wildchildclothes.com which has a new URL structure. The old site ran on Zen Cart and had a bad URL structure. Here are some examples of what I want to redirect from: OLD:...

热门标签