Mobile app version of vmapp.org
Login or Join
Gloria169

: .htaccess redirect without changing url in users' address bar My website redirects to /temp when visiting the root, I'd like it to appear as the root, without the /temp in the URL address bar.

@Gloria169

Posted in: #301Redirect #Apache #Htaccess #UrlRewriting

My website redirects to /temp when visiting the root, I'd like it to appear as the root, without the /temp in the URL address bar.

I have a simple .htaccess:

Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^$ /temp [L]


How do I make the address bar show example.com instead of example.com/temp?
Also, When I see the network panel, I notice the status code is 301, so is this equivalent to a redirect 301?

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Gloria169

1 Comments

Sorted by latest first Latest Oldest Best

 

@Ogunnowo487

RewriteRule ^$ /temp [L]


If you have a physical directory temp in the root of your filesystem... and since you have omitted the slash from the end of the RewriteRule substitution then mod_dir will attempt to "fix" the request by appending a slash. It does this by issueing a 301 redirect. (You are then presumably relying on the DirectoryIndex to serve the appropriate file from that directory.)

You can resolve this by appending a slash to the end of the substitution, so mod_dir won't try and do this by issuing a redirect. For example:

RewriteRule ^$ /temp/ [L]



I notice the status code is 301, so is this equivalent to a redirect 301


Yes, that is a 301 (permanent) redirect.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme