在我的htacess中我有:
RewriteRule ^(users)/([a-z]+)$ users.php?action=$2
当我输入网址时:site.com/users/register/
(最后是/的是)
网站将我重定向到:site.com/users.php/register/?action=register
这是做什么的?什么时候不应该重定向。
此外,当我输入网址:site.com/users/register
时,它会将我发送到错误页面!
完整代码:
Header unset ETag
FileETag None
<IfModule mod_deflate.c>
SetOutputFilter DEFLATE
</IfModule>
<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault A86400
ExpiresByType image/x-icon A2592000
ExpiresByType image/ico A2592000
ExpiresByType application/x-javascript A2592000
ExpiresByType text/css A2592000
ExpiresByType image/gif A604800
ExpiresByType image/png A604800
ExpiresByType image/jpeg A604800
ExpiresByType text/plain A604800
ExpiresByType application/x-shockwave-flash A604800
ExpiresByType video/x-flv A604800
ExpiresByType application/pdf A604800
ExpiresByType text/html A900
</IfModule>
<FilesMatch "\.(flv|gif|jpg|jpeg|png|ico|swf)$">
Header set Cache-Control "max-age=7257600"
</FilesMatch>
# 1 Week
<FilesMatch "\.(js|css|pdf|txt)$">
Header set Cache-Control "max-age=7257600"
</FilesMatch>
# 10 Minutes
<FilesMatch "\.(html|htm)$">
Header set Cache-Control "max-age=3600"
</FilesMatch>
<ifModule mod_gzip.c>
mod_gzip_on Yes
mod_gzip_dechunk Yes
mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
mod_gzip_item_include handler ^cgi-script$
mod_gzip_item_include mime ^text/.*
mod_gzip_item_include mime ^application/x-javascript.*
mod_gzip_item_exclude mime ^image/.*
mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
</ifModule>
#Gzip
<ifmodule mod_deflate.c>
# compress text, HTML, JavaScript, CSS, and XML
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# remove browser bugs
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</ifmodule>
#End Gzip
# NONE
<FilesMatch "\.(pl|php|cgi|spl)$">
Header unset Cache-Control
Header unset Expires
Header unset Last-Modified
FileETag None
Header unset Pragma
</FilesMatch>
ErrorDocument 404 http://www.site.ae
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(RSS)/([A-Z][a-zA-z0-9]+).xml$ rss.php?title=$2
RewriteRule ^(articles)/(.*)/$ article.php?s=$2
RewriteRule ^(articles)/(.*)/([0-9]+)$ article.php?s=$2&page=$3
RewriteRule ^(teams)/(.*)/$ teams.php?s=$2
RewriteRule ^(teams)/(.*)/([0-9]+)$ teams.php?s=$2&page=$3
RewriteRule ^(site)/(all)/$ site.php?s=$2
RewriteRule ^(site)/(all)/([0-9]+)$ site.php?s=$2&page=$3
RewriteRule ^(site)/(tag)/(.*)/(.*)/([A-Z]+)/([0-9]+)$ site.php?s=tag&orderby=$4&order=$5&tag=$3&page=$6
RewriteRule ^(site)/(.*)/(.*)/([A-Z]+)/([0-9]+)$ site.php?s=$2&orderby=$3&order=$4&page=$5
RewriteRule ^([A-Z][a-zA-z0-9]+)/?$ show_site.php?title=$1
RewriteRule ^([A-Z][a-zA-z0-9]+)/([0-9]+)/([0-9]+)/?$ show_chapter.php?title=$1&ch_num=$2&page=$3
RewriteRule ^([A-Z][a-zA-z0-9]+)/([0-9]+)/?$ show_chapter.php?title=$1&ch_num=$2&page=C
RewriteRule ^(t)/(.*)/$ team.php?t=$2
RewriteRule ^(t)/(.*)/([0-9]+)$ team.php?t=$2&page=$3
RewriteRule ^(contact)/?$ contact.php
RewriteRule ^(add)/(chapter)?$ addchapter.php
RewriteRule ^(add)/(site)?$ addsite.php
RewriteRule ^(add)/(info)?$ addinfo.php
RewriteRule ^(register)/?$ register.php
RewriteRule ^(user)/(.*)/$ usercp.php?page=favorite&user=$2
RewriteRule ^(my-list)/delete/([0-9]+)/$ usercp.php?page=delete&site=$2
RewriteRule ^(my-list)/add/([0-9]+)/$ usercp.php?page=add&site=$2
RewriteRule ^(review)/([A-Z][a-zA-z0-9]+)/$ addreview.php?m=$2
RewriteRule ^(users)/([a-z]+)$ users.php?action=$2
RewriteRule ^(showarticle)/([0-9]+)/$ showarticle.php?id=$2
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?siteat.com
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?site.ae [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://i642.photobucket.com/albums/uu145/shnisaka/nohotlinking_zpsf5dd3133.jpg [NC,R,L]
RewriteCond %{HTTP_HOST} ^site.ae$
RewriteRule ^(.*)$ "http\:\/\/www\.site\.ae\/$1" [R=301,L]
更精致的问题:
RewriteRule ^(users)/(register)$ users.php?action=register [R=301,L]
应该从site.com/users.php?action=register
重定向到site.com/users/register
吗?
答案 0 :(得分:0)
保持这样的规则:
Options +FollowSymlinks -MultiViews
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?siteat\$.com
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?site\.ae$ [NC]
RewriteRule \.(jpg|jpeg|png|gif)$ http://i642.photobucket.com/albums/uu145/shnisaka/nohotlinking_zpsf5dd3133.jpg [NC,R,L]
RewriteCond %{HTTP_HOST} ^site\.ae$
RewriteRule ^(.*)$ http://www.site.ae/$1 [R=301,L,NE]
RewriteCond %{REQUEST_FILENAME} -d [OR]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^ - [L]
RewriteRule ^(RSS)/([A-Z][a-zA-z0-9]+).xml$ rss.php?title=$2 [L,QSA]
RewriteRule ^(articles)/(.*)/$ article.php?s=$2 [L,QSA]
RewriteRule ^(articles)/(.*)/([0-9]+)$ article.php?s=$2&page=$3 [L,QSA]
RewriteRule ^(teams)/(.*)/$ teams.php?s=$2 [L,QSA]
RewriteRule ^(teams)/(.*)/([0-9]+)$ teams.php?s=$2&page=$3 [L,QSA]
RewriteRule ^(site)/(all)/$ site.php?s=$2 [L,QSA]
RewriteRule ^(site)/(all)/([0-9]+)$ site.php?s=$2&page=$3 [L,QSA]
RewriteRule ^(site)/(tag)/(.*)/(.*)/([A-Z]+)/([0-9]+)$ site.php?s=tag&orderby=$4&order=$5&tag=$3&page=$6 [L,QSA]
RewriteRule ^(site)/(.*)/(.*)/([A-Z]+)/([0-9]+)$ site.php?s=$2&orderby=$3&order=$4&page=$5 [L,QSA]
RewriteRule ^([A-Z][a-zA-z0-9]+)/?$ show_site.php?title=$1 [L,QSA]
RewriteRule ^([A-Z][a-zA-z0-9]+)/([0-9]+)/([0-9]+)/?$ show_chapter.php?title=$1&ch_num=$2&page=$3 [L,QSA]
RewriteRule ^([A-Z][a-zA-z0-9]+)/([0-9]+)/?$ show_chapter.php?title=$1&ch_num=$2&page=C [L,QSA]
RewriteRule ^(t)/(.*)/$ team.php?t=$2 [L,QSA]
RewriteRule ^(t)/(.*)/([0-9]+)$ team.php?t=$2&page=$3 [L,QSA]
RewriteRule ^(contact)/?$ contact.php [L,QSA]
RewriteRule ^(add)/(chapter)?$ addchapter.php [L]
RewriteRule ^(add)/(site)?$ addsite.php [L]
RewriteRule ^(add)/(info)?$ addinfo.php [L]
RewriteRule ^(register)/?$ register.php [L]
RewriteRule ^(user)/(.*)/?$ usercp.php?page=favorite&user=$2 [L,QSA]
RewriteRule ^(my-list)/delete/([0-9]+)/?$ usercp.php?page=delete&site=$2 [L,QSA]
RewriteRule ^(my-list)/add/([0-9]+)/?$ usercp.php?page=add&site=$2 [L,QSA]
RewriteRule ^(review)/([A-Z][a-zA-z0-9]+)/?$ addreview.php?m=$2 [L,QSA]
RewriteRule ^(users)/([a-z]+)/?$ users.php?action=$2 [L,QSA]
RewriteRule ^(showarticle)/([0-9]+)/?$ showarticle.php?id=$2 [L,QSA]
答案 1 :(得分:0)
RewriteRule ^users/([a-z]+)/?$ users.php?action=$1
RewriteRule ^users/activate/([a-zA-Z0-9]+)/([a-z]+)/?$ users.php?action=activate&Hash=$1&UserName=$2
RewriteCond %{THE_REQUEST} users\.php
RewriteRule ^users\.php - [F]
我不得不删除我的.htaccess并将其添加到其中。它没有任何问题!