我在我的CMS中生成了?pg = 1鏈接的分頁插件。我想在沒有這個醜陋的後綴的情況下重定向這個URL,因爲沒有它,CMS也會顯示第一頁。通過.htacess從URL刪除醜陋?pg = 1 RewriteRule
所以,我有一個像http://site.ru/category/schock-crane/?pg=1
或http://site.ru/moyka/?type=granit&pg=1
網址我想這樣的URL重定向到http://site.ru/category/schock-crane/
和http://site.ru/moyka/?type=granit
respectly。
這個我試過的.htaccess代碼
RewriteRule (.*)(&|\?)pg=1$ $1 [R=301,L]
我想在正則表達式培訓師這個正則表達式的代碼 - 它的工作。但是在服務器上不會發生重定向。
這裏是整個.htaccess文件:
AddDefaultCharset Off
#DirectoryIndex index.php index.html
Options +FollowSymLinks
Options -Indexes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase/
# fix /?pg=1
RewriteRule (.*)(&|\?)pg=1$ $1 [R=301,L]
# fix .palitra-tab
RewriteCond %{REQUEST_URI} -tab$
RewriteRule (.*)/([0-9]*)/\.(.*)-tab?$ http://site.ru/redirect.php?id=$2 [R=301,L]
RewriteCond %{REQUEST_URI} ^/csss/.* [NC]
RewriteRule csss/(.*)\.css$ css.php?n=$1 [L]
#RewriteRule ^(.*)/csss/(.*) /test.php [L]
RewriteRule ^(.*)/base([0-9]+)/?$ $1?base=$2
#RewriteCond %{REQUEST_FILENAME} -f
#RewriteRule \.(gif|jpeg|jpg|png)$ /images/watermark/index.php [L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) - [PT,L]
RewriteCond %{REQUEST_URI} !=/favicon.ico
RewriteRule ^(.*) index.php
RewriteCond %{HTTP:Authorization} !^$
RewriteRule .* - [E=REMOTE_USER:%{HTTP:Authorization}]
</IfModule>
是遠程服務器上啓用'mod_rewrite'?如果刪除''條件會發生什麼? –
2011-01-05 01:10:39
mod_rewrite工程 - CMS成功使用乾淨網址 – 2011-01-05 01:30:15