Tag Info

Hot answers tagged

6

The way that you will do the 301 redirect does not play any role for the Google. Actually it does not see your configuration file. What it is important is to send the 301 headers with the new location on each old url and not just the home page. For example if you have 10 pages on the old website, make sure that these all pages are redirected to the new 10 ...


5

Just redirect by 301 HTTP status all your old URLs to the new ones. If you only change file extension, you can do it easily with an .htaccess file (if you use Apache as a web server). Put these lines in your .htaccess file: RedirectMatch 301 (.*)\.html$ http://www.example.com$1.php Of course, change www.example.com by your domain name. By using 301 ...


4

You're almost there. Drop the very first RewriteCond (as it's not required and won't match ever) and add a trailing / to your last RewriteRule since you're redirecting with them. RewriteEngine On RewriteCond %{HTTP:Accept-Language} ^en [NC] RewriteRule ^$ http://mysite.com/en/ [L,R=301] RewriteCond %{HTTP:Accept-Language} ^de [NC] RewriteRule ^$ ...


4

You can use one of these solutions: Keep the Current .html extension unchanged for just frontend purpose and use Apache .htaccess file to proxify your requests so that. Add this to your .htaccess file to work: RewriteEngine on RewriteRule ^(.*).html $1.php OR Why not just have the HTML pages parsed as PHP? That way you can get the best of ...


3

The pseudo-code translation of your .htaccess file would be something along these lines: Line 1: In case we weren't previously planning to do anything special with URLs, we are now (RewriteEngine is an optional processing module and we're making sure its enabled). Line 2: When we're talking about rewrite URLs, from here on append the path /, which in your ...


3

You need to enable the rewrite engine in your .htaccess file if you have not done already... RewriteEngine on RewriteCond %{HTTP_HOST} ^www\.example\.com$ [NC] RewriteRule ^(.*)$ http://example.com/$1 [L,R=301] Note that I've removed the extra .com on the RewriteCond line that you have in your question - I'm assuming this was a typo? Also, FollowSymLinks ...


2

To isolate the problem, first try it without the redirect. If it still doesn't work, then make sure that the httpd user (e.g. nobody) has read access to the GeoIP database files, as covered in the Troubleshooting section here. Also make sure that each line in your .htaccess file or main server config ends in a newline, and remove the spacing before ...


2

Does purposely and permanently having invalid URLs on your site that get 301'ed to the correct ones have any effect on SEO? I could make it just show the correct URL to begin with, but this is a significant amount of work due to how I am handling the translations, so I would prefer just to 301 them. Arguably, yes. According to Google, a 301 ...


2

As mentioned in comments above, you'll need a RewriteCond directive in order to prevent an internal rewrite loop. Whilst the L flag terminates the current rule set, the entire process is started again with the rewritten URL, so we need a get-out clause. RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{QUERY_STRING} !^fid= RewriteRule ...


2

RewriteCond %{HTTP_HOST} ^tech\.doig\.com\.au$ [NC] RewriteRule . - [S=120] You appear to be Skipping all of the relevant redirects when the HOST matches tech.doig.com.au, which would seem to be the opposite of what you are trying to achieve. As it stands, your redirect would only occur when the domain is not tech.doig.com.au. It looks like your ...


2

If you are changing an existing URL structure then you will need to redirect the old (ugly) URLs to the new (pretty) URLs, rather than reject them with a 403 response. If it's a brand new site then you could reject them with a 404 (R=404) - preferable to a 403 I think in this instance. Something like the following (placed before your existing rewrites): ...


2

You have RewriteEngine On missing RewriteCond are only applicable to next immediate RewriteRule Try this code: RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-l RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^explore/(.*)$ index.php?page=explore&type=$1 [L] RewriteCond %{REQUEST_FILENAME} !-l ...


2

You just need to change the URL structure in the same two lines: RewriteCond %{HTTP_HOST} ^www.domain.com$ [NC] RewriteRule ^(.*)$ http://domain.com/$1 [R=301,L]


2

Yes that's correct and would 301 redirect everything on oldsite.org to the same path on http://newsite.com. Plenty of similar questions on the StackExchange network such as this one.


2

Either all Options must start with + or -, or no Option may. Ah yes! This behaviour has changed with the move to Apache 2.4 - it has always been invalid - but now "will be rejected during server startup by the syntax check with an abort." Reference: Apache Docs You need to specify a + before the Indexes option: Options +Indexes +FollowSymLinks ...


2

You need to change your Redirect (mod_alias) to RewriteRule (mod_rewrite). Something like: RewriteRule ^word1/word2/word3 /word1/word2 [R=301,L] (Put back example/ if you wish, but it looked like a typo to me?) The problem you are experiencing is that mod_rewrite (nearly) always executes before mod_alias, regardless of the order of directives in your ...


2

You need to add "RewriteOptions Inherit" to each virtual server. See http://httpd.apache.org/docs/2.4/mod/mod_rewrite.html#rewriteoptions for details.


2

You can use these three rewrite rules which handle up to 3 levels of directories: RewriteEngine on RewriteRule ^main\/([^\/]+)\/([^\/]+)\/([^\/]+)\/? /parser.php?var1=$1&var2=$2&var3=$3 [L] RewriteRule ^main\/([^\/]+)\/([^\/]+)\/? /parser.php?var1=$1&var2=$2 [L] RewriteRule ^main\/([^\/]+)\/? /parser.php?var1=$1 [L] In those regular ...


2

Your root .htaccess should look like this: # Mod RewriteRules, some 12 in all RewriteRule ^mod/(.*)$ /moderator/$1 [NC,L] RewriteRule ^signup/(.*)$ /acc/signup/$1 [NC,L] RewriteRule ^signin/(.*)$ /acc/signin/$1 [NC,L] RewriteRule ^signout/(.*)$ /acc/signout/$1 [NC,L] # These are the only two that a front end user will use # category/subCategory ...


2

I suspect you are over thinking this. I am really confused over all your code. One of the things I am finding these days is that people are using example code that is already unnecessarily complicated. As well, people seem to select {???} that offers too much instead of the narrowest selection. Often these things only require 2 lines or 3 at the most and ...


2

For your first two rewrites (non-www → www, http → https), the following rule should work: RewriteEngine On RewriteCond %{HTTPS} off [OR] RewriteCond %{HTTP_HOST} !=www.example.com [NC] RewriteRule ^(.*) https://www.example.com/$1 [NS,L,R=permanent] Just replace www.example.com with the actual canonical hostname of your site. As for your third ...


1

Your rewrite rule (appropriate for a .htaccess file) would look like this: RewriteRule ^folder/link.html$ /link.html That would serve the contents of link.html at both /link.html and /folder/link.html.


1

The URLs you want to redirect to the home page are all currently handled by this rewrite rule: RewriteRule ^(.*)$ index.php?p=$1 [L] so you have a conflict. I use this WordPress plugin for these types of redirects: Quick Page Post Redirect Plugin. You have to specify all of the redirects individually rather than with a pattern, but with only 100, that ...


1

Provided you are happy with pretty URL's that do not end in / but have no file extensions shown such as .php, for example: http://subdomain.domain.com/DynamicCountry/DynamicName/file then you could try this solution. Add these lines of code in your http://subdomain.domain.com/.htaccess file: RewriteEngine on RewriteRule ...


1

Try this: RewriteRule ^(.*)\/$ $1.php [NC]


1

Browsers offer to download files based on two headers: Content-Type Content-Disposition I use a command line tool called curl to check headers on a website. curl -s -D - 'http://example.com/' | head -n 20 If you don't want your pages to be downloaded, then the Content-Type should be set to text/html or text/html;charset=UTF-8 and there should be no ...


1

I actually found out (with the help of a friend) that RewriteRule ^([a-zA-Z0-9]{3})$ get.php?fid=$1 [PT] Is sufficient. Please do comment when this statement contains any traps or security issues.


1

You won't be able to have both your Swedish content and your English content crawled and indexed by Googlebot like that. You don't say how your are determining language. Googlebot doesn't send accept-language headers, so your redirects may not even work for Googlebot. If you are redirecting based on geographic location of the IP address, Googlebot will ...


1

Neither of your attempts to get the syntax for your "Redirect 301" rules is correct. The format should be: Redirect 301 /relative-uri http://fully.qualified/url So: Redirect 301 /test.html‎ http://www.example.co.za/page/pop/test Redirect 301 /about.html‎ http://www.example.co.za/about As nathangiesbrecht says, your rewrite rule may also be ...



Only top voted, non community-wiki answers of a minimum length are eligible