我正在开发一个PHP应用程序,它将生成以下链接
http://localhost/24_2_april/video-library/2/Programming-Language
但是自从我使用htaccess使我的URL干净之后,CSS和JS就不能工作了。现在我知道我可以给出cSS的绝对路径,但我认为这不是正确的方法,我也尝试过使用RewriteCond %{REQUEST_FILENAME} !-f,但到目前为止还没有成功……
这是到目前为止我的htaccess代码。
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^video-library/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ var/www/html/24_2_april/video.php?cat_id=$1&category=$2 [L]
RewriteRule ^video-library/([A-Za-z0-9-]+)/?$ var/www/html/24_2_april/search_results.php?cat_id=$1 [L]发布于 2017-04-24 20:01:59
在我看来,最好的方法是使用RewriteCond。只有在没有实际可用的文件时,才会执行这些重写规则。如果您的文件是符号链接,则可能需要添加RewriteCond %{REQUEST_FILENAME}% !-l
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME}% !-f
RewriteCond %{REQUEST_FILENAME}% !-d
RewriteRule ^video-library/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ var/www/html/24_2_april/video.php?cat_id=$1&category=$2 [L]
RewriteCond %{REQUEST_FILENAME}% !-f
RewriteCond %{REQUEST_FILENAME}% !-d
RewriteRule ^video-library/([A-Za-z0-9-]+)/?$ var/www/html/24_2_april/search_results.php?cat_id=$1 [L]发布于 2017-04-24 20:03:26
尝尝这个
Options +FollowSymLinks
RewriteEngine On
RewriteRule ^video-library/([A-Za-z0-9-]+)/([A-Za-z0-9-]+)/?$ http://localhost/24_2_april/video.php?cat_id=$1&category=$2 [L]
RewriteRule ^video-library/([A-Za-z0-9-]+)/?$ http://localhost/24_2_april/search_results.php?cat_id=$1 [L]https://stackoverflow.com/questions/43587462
复制相似问题