我制作了一个.htaccess文件,让我的网址看起来像 http://www.domain.com/ar/?page=article&id=20 至 http://www.domain.com/ar/article/20
到目前为止我已经用
制作了它Options -ExecCGI +Includes -IncludesNOEXEC -Indexes -SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule ^([^/]*)/([^/]*)$ /ar/?page=$1&id=$2 [L]
但是.. 所有的文件(css,js,图像)都被破坏了..我试图尽可能地使它绝对(通过添加/到每个src的开头)没有运气
.. 如何加载文件?
如何将网址重定向(?page = contact to ar / contact .. not to ar / topic / 20 /?page = contact)?
以及如何在我的网址中包含任何其他意外参数?
答案 0 :(得分:0)
我不太确定,但试试这个。
Options +FollowSymLinks
RewriteEngine On
# with html base href in header: <base href="http://<?=$_SERVER['HTTP_HOST']?>/" />
RewriteBase /
# deny rules to url rewrite for specific file types in website root folder
RewriteRule ^/?(.*).(php|css|ico|js|log|png|jpg|gif|jpeg)$ - [L]
# deny rules to url rewrite for folders (if needed)
RewriteRule ^(css|images)($|/) - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# and the mapping rule. index.php is your basic file for example
# $1 -> ar/ $2 -> article/$3 -> 20
RewriteRule ^([^/]*)/([^/]*)/([^/]*)$ index.php?module=$1&page=$2&id=$3 [L]
Options SymLinksIfOwnerMatch
答案 1 :(得分:0)
您需要为重写规则添加条件。试试这个。
Options -ExecCGI +Includes -IncludesNOEXEC -Indexes -SymLinksIfOwnerMatch
RewriteEngine On
RewriteCond %{REQUEST_URI} !.*\.(css¦jpg¦gif¦png¦js)
RewriteRule ^([^/]*)/([^/]*)$ /ar/?page=$1&id=$2 [L]
如果请求的文件没有CSS,JPG,GIF,PNG或JS的扩展名,则只会重写URL。
编辑纠正了语法错误。