Forum Moderators: phranque

Message Too Old, No Replies

htaccess redirect 301

301

         

ControlZ

6:31 pm on Aug 20, 2014 (gmt 0)

10+ Year Member



I am having difficulty figuring out why www.Example.com redirects to www.Example.com/index

I do have an SSL installed so there is a rewrite rule in place for this but perplexed as to what in my current htaccess file is causing the URL to show as https:www.Example.com/index.php instead of [Example.com...]

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ [Example.com...] [R,L]

# BEGIN GZIP
<ifmodule mod_deflate.c>
AddOutputFilterByType DEFLATE text/text text/html text/plain text/xml image/svg+xml text/css application/x-javascript application/javascript
</ifmodule>
# END GZIP

<IfModule mod_expires.c>
# Enable expirations
ExpiresActive On
# Default directive
ExpiresDefault "access plus 1 month"
# My favicon
ExpiresByType image/x-icon "access plus 1 year"
# Images
ExpiresByType image/gif "access plus 1 month"
ExpiresByType image/png "access plus 1 month"
ExpiresByType image/jpg "access plus 1 month"
ExpiresByType image/svg "access plus 1 month"
# CSS
ExpiresByType text/css "access 1 month"
# Javascript
ExpiresByType application/javascript "access plus 1 year"
</IfModule>

AddDefaultCharset UTF-8

# Permanent URL redirect
Redirect 301 /contact.html http://www.example.com/

Redirect 301 /work.html http://www.example.com/

Redirect 301 /index.html http://www.example.com/

Redirect 301 /folio.html http://www.example.com/

Redirect 301 /folio3.html http://www.example.com/

Redirect 301 /folio2.html http://www.example.com/

Redirect 301 /inside.html http://www.example.com/

Redirect 301 /hamel/ http://www.example.com/

Redirect 301 /print_folio3.html http://www.example.com/

Redirect 301 /print_folio2.html http://www.example.com/

Redirect 301 /website_design.html http://www.example.com/

Redirect 301 /web-site-design.html http://www.example.com/

Redirect 301 /web-design-testimonials.html http://www.example.com/

Redirect 301 /web-design-testimonials2.html http://www.example.com/

Redirect 301 /web-design-testimonials3.html http://www.example.com/

Redirect 301 /testimonials.pdf http://www.example.com/

Redirect 301 /web-development-clients.html http://www.example.com/

Redirect 301 /images.xml http://www.example.com/

Redirect 301 /flash/gallery.swf http://www.example.com/

ErrorDocument 403 /403.shtml
ErrorDocument 404 /404.shtml
ErrorDocument 500 /500.shtml

[edited by: Ocean10000 at 7:27 pm (utc) on Aug 20, 2014]
[edit reason] Examplfied. [/edit]

not2easy

6:57 pm on Aug 20, 2014 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I guess now you can see why the forums here ask us to use "example.com" in place of actual or substitute domain names.

Basically you have not got any rewrite for index in the list here, so it is not being redirected.

Is there a reason why your 301 rewrites don't use the https: versions?

ControlZ

7:08 pm on Aug 20, 2014 (gmt 0)

10+ Year Member



My bad, I saw website.com used on another posting and assumed it was fine.

I suppose the 301s could use https, however if I had a rule in place that directed index to just the domain name I think I would be fine, no?

I am not sure how to direct index to the domain, in other words [example.com....] Would you mind giving me some advice?

lucy24

8:12 pm on Aug 20, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you are using mod_rewrite at all, you will need to translate all your mod_alias redirects to mod_rewrite syntax. (There's a bit of boilerplate that shows how to do it globally in a text editor.) Otherwise you risk having things execute in the wrong order.

[R] is not 301, it's 302. A possible further problem is that your quoted RewriteRule has neither the [NS] flag nor a RewriteCond looking at {THE_REQUEST} -- so there doesn't seem to be anything to keep the rule from kicking in after an internal request for index.xtn (invoked by mod_dir because that's its job).