Skip to content Skip to sidebar Skip to footer

How To Hide A Subfolder In Url Rewriting

My site is : www.mysite.com/subfolder/login/index.php I want the URL there to just be www.mysite.com/login/index.php. I tried modifying the .htaccess file in the root folder as fol

Solution 1:

# fix js/images/css
RewriteRule ^.+?/((img|css|js)/.+)$ /subfolder/login/$1 [L,NC]

Try adding this as your first rule in htaccess. Or you can use

# fix js/images/css
RewriteRule ^.+?/((img|css|js)/.+)$ http://www.yourdomain.com/subfolder/login/$1 [L,NC]

You can see more examples and ways of rewriting here: https://wiki.apache.org/httpd/Rewrite


Solution 2:

Add Another rule for css, or use absolute CSS path e.g.:

RewriteRule login\(.*)\.css /subfolder/login/$1.css [L]

Solution 3:

The title does not seem to match the question at the end of your description, but to answer the latter: If you have a problem with your assets (images, css, external javascript, etc.) after url rewriting, use absolute paths, for example:

/subfolder/login/style.css

instead of something like:

../style.css    /* this will probably not work when rewriting urls */

Post a Comment for "How To Hide A Subfolder In Url Rewriting"