Forum Moderators: phranque
RewriteRule ^/?(.+)$ /darkalfx/$1 My website is actually hosted in the subfolder /darkalfx so when people go to my website I want to redirect them there, however I don't want to show /darkalfx/ after my website name on every page so I wish to remove it entirely from the URL.
RewriteRule ^/?(.+)$ /darkalfx/$1
httpd.conf. In .htaccess the leading slash is not present. Requested paths and files are localised "per-directory" in .htaccess. (www.)example.com/darkalfx/<something> they are redirected to www.example.com/<something> and if they request example.com/<something> they are redirected to www.example.com/<something>. /darkalfx, index files are dealt with first, then everything else. DirectoryIndex index.php index.html
# Externally redirect only direct client requests for /index.php and
# /index.html and /index.htm with /darkalfx to root URL ending with slash.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /darkalfx/([^/]+/)*index\.(html?|php)\ HTTP/
RewriteRule ^darkalfx/(([^/]+/)*)index.(html?|php)$ http://www.example.com/$1 [R=301,L]
# Externally redirect only direct client requests for /darkalfx<something>
# to www.example.com/<something>.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /darkalfx([^\ ]+)\ HTTP/
RewriteRule ^darkalfx(.*) http://www.example.com/$1 [R=301,L]
# Externally redirect only direct client requests for /index.php
# and /index.html and /index.htm to URL ending with slash.
RewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /([^/]+/)*index\.(html?|php)\ HTTP/
RewriteRule ^(([^/]+/)*)index.(html?|php)$ http://www.example.com/$1 [R=301,L]
# Externally redirect to canonicalize the domain name if a non-canonical
# hostname is requested, in order to prevent duplicate-content problems
RewriteCond %{HTTP_HOST} !^(www\.example\.com)?$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
# Internally rewrite requests for www.example.com/<anything>
# to internal server path at /darkalfx/<anything>
RewriteCond %{REQUEST_URI} !^/darkalfx
RewriteRule (.*) /darkalfx/$1 [L] href="/images/image.png". Think of their location in terms of URLs.