Forum Moderators: phranque
Redirect 301 page page.html [edited by: incrediBILL at 10:10 pm (utc) on Aug 21, 2012]
[edit reason] fixed code display issue [/edit]
# Force a redirect of "example.com/webpage" to "www.example.com/webpage.html"
RewriteRule ^webpage$ /webpage.html [L]
RewriteCond %{HTTP_HOST} ^example\.com [NC]
is it right that adding a line into my .htaccess file like:
RewriteLog "rewrite.log"
I want to be able to advertise (in print) a URL such as www.example.com/webpage, which would be redirected to the page www.example.com/webpage.html
bt.com/phonebook - is that sort of what you want?
I'm quite happy for the address bar to show the proper, full URL to the visitor when they get there.
the bt.com/phonebook example you give is also more complex than I need.
bt.com/phonebook and are redirected to the real page with a much longer URL that you don't need to remember because you have a "short" URL that redirects to it. You have a file at /page.html
Ordinarily you would use the URL example.com/page.html to access it.
With a rewrite you can link to href="/page" and when example.com/page is requested, the request is rewritten to fetch the content from the file at /file.html without the browser address bar changing.
You can now access the page at two different URLs, both of which return "200 OK" status.
try reading the redirect/rewrite explanation out loud
We don't talk much about "hackable URLs" here, but it's something I have done for years. Pick a range of URLs that users might guess and type in when attempting to find particular pages and set redirects to the right place for those requests.
that's why I always make sure to have a "webmaster@" e-mail address. Someone might try it.