mod_rewrite image problems
I currently have this in .htaccess:
Options +FollowSymlinks
RewriteEngine on
RewriteRule ^page/(.*)/(.*)$ /type1/internal.php?parentFolders=$1&pageTitleID=$2 [L]
When I visit http://localhost/type1/page/home/play
it works fine, however I would like 开发者_运维百科to take the /page/
out therefore being http://localhost/type1/home/play
I have tried the following:
RewriteRule ^(.*)/(.*)$ /type1/internal.php?parentFolders=$1&pageTitleID=$2 [L]
however some images seem to vanish, and some don't.
Also, I find hard links in my nav do not work either as they are asking for variables used in internal pages.
I am not sure if this is a absolute/relative problem as my CSS is written as
<link href="http://localhost/type1/global.css" rel="stylesheet" type="text/css" />
and links seem to be full links when I inspect them with my browser!?
Any help would be great
As I understand the .htaccess file is located in /type1/
subfolder. Try these rules:
Options +FollowSymLinks -MultiViews
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]+)/(.*)$ /type1/internal.php?parentFolders=$1&pageTitleID=$2 [L,QSA]
The
(.*)
pattern you are using is too broad for first parameter, I use([^/]+)
instead (any character except slash).Added 2 rewrite conditions .. so only requests to non-existing files and folders will be rewritten. This should help with disappeared images (or may not -- it all depends how how the links are written).
Added
QSA
flag to preserve any existing query string.
精彩评论