unemployment Posted September 20, 2013 Share Posted September 20, 2013 How do you do a simple path rewrite in .htaccess? I need my localhost/blog url to access the content located in localhost/assets/blog . How do I make this rule occur in htaccess? My full .htaccess code: <IfModule mod_rewrite.c> Options +FollowSymlinks -MultiViews RewriteEngine On </IfModule> RewriteCond %{HTTP_HOST} ^www.mysite.com$ [NC] RewriteRule ^(.*)$ http://mysite.com/$1 [R=301,L,S=4] # If requested resource exists as a file or directory, skip next three rules RewriteCond %{DOCUMENT_ROOT}/$1 -f [OR] RewriteCond %{DOCUMENT_ROOT}/$1 -d RewriteRule (.*) - [S=3] # Blog articles. # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_FILENAME} !-d # RewriteRule ^/?blog/([^/]+)/(\d+)/(\d+)$ blog.php?title=$1&id=$2&reply_to=$3 [L,S=1] # RewriteCond %{REQUEST_FILENAME} !-f # RewriteCond %{REQUEST_FILENAME} !-d # RewriteRule ^/?blog/([^/]+)/(\d+)$ blog.php?title=$1&id=$2 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(blog/.*)$ /assets/$1 [L,NC] # Remove the .php extension RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^([^\.]+)$ $1.php [NC,L] # for copying #RewriteCond %{REQUEST_FILENAME} !-f #RewriteCond %{REQUEST_FILENAME} !-d #RewriteRule ^(.*)$ index.php?page=$1 [L] RewriteRule (.*)\.xml(.*) $1.php$2 [nocase] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ app.php?tag=$1 [QSA,L] # ---------------------------------------------------------------------- # Custom 404 page # ---------------------------------------------------------------------- # You can add custom pages to handle 500 or 403 pretty easily, if you like. ErrorDocument 403 /error.php?type=403 ErrorDocument 404 /error.php?type=404 ErrorDocument 500 /error.php?type=500 Link to comment https://forums.phpfreaks.com/topic/282317-htacces-path-rewrite-to-get-contents-from-a-different-folder/ Share on other sites More sharing options...
jazzman1 Posted September 21, 2013 Share Posted September 21, 2013 I need my localhost/blog url to access the content located in localhost/assets/blog . Alias directive provides mapping to different parts of the host filesystem in the document tree. Link to comment https://forums.phpfreaks.com/topic/282317-htacces-path-rewrite-to-get-contents-from-a-different-folder/#findComment-1450586 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.