1
我試圖創造清潔URL和創建清潔的URL到目前爲止,我已經成功地使用的.htaccess以下URL轉換:取得PHP讀取由.htacces
www.example.com/index ?.PHP產品類別= SECTION1 &頁=第1頁
到:
www.example.com/Section1/Page1/
這個問題就越來越PHP解釋URL並提取變量。下面是我使用的代碼:
的.htaccess代碼:
Options +FollowSymLinks
Options +Indexes
RewriteEngine on
INTERNAL STATIC URL TO DYNAMIC URL
RewriteRule ^/([^/]+)/?$ /index.php?c=$1 [L]
RewriteRule ^/([^/]+)/([^/]+)/?$ /index.php?c=$1&p=$2 [L]
EXTERNAL DYNAMIC URL TO STATIC URL
RewriteCond %{THE_REQUEST} ^[a-zA-Z0-9]{1,3}\ /index\.php\?catagory=([^&]+)\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/%1/? [R=301,L]
RewriteCond %{THE_REQUEST} ^[a-zA-Z0-9]{1,3}\ /index\.php\?catagroy=([^&]+)&page=([^&]+)\ HTTP/
RewriteRule ^index\.php$ http://www.example.com/%1/%2/? [R=301,L]
PHP代碼:
$urlVariables = explode("/",$_SERVER['REQUEST_URI']);
$catagory = $urlVariables[1];
$page = $urlVariables[2];
有了這個,我不斷收到一個404錯誤頁面。如果我添加的index.php到這條線的htacces代碼:
RewriteRule ^index\.php$ http://www.example.com/index.php/%1/? [R=301,L]
頁至少加載,但CSS和圖像不加載。