Welcome to WebmasterWorld Guest from 54.80.140.29

Forum Moderators: Ocean10000 & phranque

htaccess problem by generating non www and ww urls

     
6:19 pm on Mar 5, 2018 (gmt 0)

New User

joined:Dec 20, 2017
posts: 37
votes: 0


My problem is that if I do a site: command in google, I get 3 differnt url structures:

www.example.com
https://example.com
https://www.example.com

wordpress is set at https://example.com

I think the mixture is affecting my rankings in google
So i am including my htaccess here for you to see if anything looks wrong to you
Thanks.
Arturo

RedirectMatch 410 ^/jewellery-logo-2
RedirectMatch 410 ^/accurist-new-logo


RedirectMatch 410 https://example.com/shop/


RewriteRule proddet\.asp http://www.example.com/department/gifts/willow-tree/ [R=301,L]
# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon image/webp application/json application/vnd.ms-access application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.presentation application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint image/svg+xml application/x-shockwave-flash image/tiff application/x-font-ttf application/vnd.ms-opentype audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
<FilesMatch "\.(html|htm|rtf|rtx|svg|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|TXT|XSD|XSL|XML)$">
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
</FilesMatch>
<FilesMatch "\.(bmp|class|doc|docx|eot|exe|ico|webp|json|mdb|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|pot|pps|ppt|pptx|svg|svgz|swf|tif|tiff|ttf|ttc|_ttf|wav|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|BMP|CLASS|DOC|DOCX|EOT|EXE|ICO|WEBP|JSON|MDB|MPP|OTF|_OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|POT|PPS|PPT|PPTX|SVG|SVGZ|SWF|TIF|TIFF|TTF|TTC|_TTF|WAV|WRI|WOFF|WOFF2|XLA|XLS|XLSX|XLT|XLW)$">
<IfModule mod_headers.c>
Header unset Last-Modified
</IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} =on
RewriteRule .* - [E=W3TC_SSL:_ssl]
RewriteCond %{SERVER_PORT} =443
RewriteRule .* - [E=W3TC_SSL:_ssl]
RewriteCond %{HTTP:X-Forwarded-Proto} =https [NC]
RewriteRule .* - [E=W3TC_SSL:_ssl]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
RewriteRule .* - [E=W3TC_PREVIEW:_preview]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{REQUEST_URI} \/$
RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
4:01 am on Mar 6, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15027
votes: 665


FIrst things first: Get rid of all commands using Redirect(Match) by that name. Those are mod_alias directives, which don't play nice with mod_rewrite. Don't eliminate the redirects themselves, of course; instead change the rules to mod_rewrite syntax. It looks as if you just need a couple of RewriteRules with the [G] flag.
4:16 am on Mar 6, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11393
votes: 157


you will need to add a hostname canonicalization ruleset before the WP internal rewrite.
there are plenty of examples in this forum.
4:28 am on Mar 6, 2018 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:3909
votes: 223


Just a note - this discussion began as a discussion of URLs with added protocol prefix issue, see: [webmasterworld.com...]

If an URL is entered with www, it is converted by adding a non-www prefix as in:
https://domain.com/https://www.domain.com/ukgs_logo/
7:02 am on Mar 6, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11393
votes: 157


Arturo99, regarding this url:
https://domain.com/https://www.domain.com/ukgs_logo/


how does your server respond to requests for this url?
are you finding this url in links on your site?
are you finding this url when a request is redirected with a 301/302 status code?
are you only finding this url in GSC?
have you checked your server access logs to see if any site might be referring that url?
7:38 am on Mar 6, 2018 (gmt 0)

Moderator from US 

WebmasterWorld Administrator keyplyr is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Sept 26, 2001
posts:12333
votes: 805


https://domain.com/https://www.domain.com/
Each time I've seen this problem there was a conflict between a server redirect and account redirect.

Either WP has a redirect or the host has a redirect that is conflicting with the one that has been added in htaccess.

While the issue doesn't affect humans using major browsers, it seems to intermittently affect some crawlers. I've seen this with both Bingbot and Googlebot.

This could absolutely affect SERP ranking.
9:41 am on Mar 6, 2018 (gmt 0)

New User

joined:Dec 20, 2017
posts: 37
votes: 0


Lucy24
---------
Even with a 410 on specific urls above, the urls STILL appear
on a site command in google, and have done so for about 8 weeks.
(I note what you say about changing to mod _rewrite)


phranque
------------
what is a hostname canonicalisation?
and do you mean write it in wp admin?

...https://domain.com/https://www.domain.com/ukgs_logo/
server repsonse is:
...https://domain.com/https://www.domain.com/ukgs_logo/
with a 404 error

My problem url does not exist in links in my site

Yes I am only finding this url in GSC
You can see it on a site: command
100 of the out of a total of 400 ulrs


These are the only ones that give a 301 on a crawl by screaming frog
Screaming frog does not find my problem url
...https://domain.com/https://www.domain.com/ukgs_logo/
Only Google shows it on a site command.

I have approx 40 urls with 301 statements such as
Redirect 301 /watches/ice/ /department/watches/
Redirect 301 /collectables/lolita/ /department/gifts/
They all work ok, no bad url.
10:19 am on Mar 6, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11393
votes: 157


what is a hostname canonicalisation?[

the basic http-to-https and non-www-to-www redirect ruleset for example.com would look something like:

RewriteCond {HTTP_HOST} !^(www\.example\.com)?$ [NC,OR]
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]


the only problem this solves is that [domain.com...] will get redirected to [domain.com...]

server repsonse is:
...https://domain.com/https://www.domain.com/ukgs_logo/
with a 404 error

this is an appropriate response and i would not consider this an "error" even if GSC uses that terminology.

if at some point you determined that requests for these urls were being referred to from a link on a relevant and authoritative site incorrectly linking to you , you have two choices:
- get the site owner to change the url so that it is correct
- add another ruleset to redirect urls that look like this to the correct path on the canonical protocol and hostname.

I have approx 40 urls with 301 statements such as
Redirect 301 /watches/ice/ /department/watches/

change all these Redirect directives to the equivalent RewriteRule syntax.
7:34 pm on Mar 6, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15027
votes: 665


I have approx 40 urls with 301 statements
40 of them? Then it's time to fire up a text editor that does Regular Expressions, make a copy of your htaccess file, and apply these global changes (replace \1 with $1 depending on your RegEx engine):

^Redirect(?:Match)? 301 /(.+)
TO
RewriteRule \1 [R=301,L]

^Redirect(?:Match)? 410 /(.+)
TO
RewriteRule \1 - [G]

^Redirect(?:Match)? 403 /(.+)
TO
RewriteRule \1 - [F]
9:30 am on Mar 7, 2018 (gmt 0)

New User

joined:Nov 28, 2016
posts:10
votes: 0


Lucy24
FIrst things first: Get rid of all commands using Redirect(Match) by that name. Those are mod_alias directives, which don't play nice with mod_rewrite. Don't eliminate the redirects themselves, of course; instead change the rules to mod_rewrite syntax. It looks as if you just need a couple of RewriteRules with the [G] flag.


Can you tell me how i change the redirectmatches to mod rewrite rules with [G] flags?
9:37 am on Mar 7, 2018 (gmt 0)

New User

joined:Nov 28, 2016
posts:10
votes: 0


ps. thaks fro the code on the 301s.
9:38 am on Mar 7, 2018 (gmt 0)

New User

joined:Nov 28, 2016
posts:10
votes: 0


Does your last message also handle the redirect match statements i should remove?
9:34 pm on Mar 7, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15027
votes: 665


The three global replaces I listed cover the three most common situations: Redirect as such (301); Gone (410 response, G flag in mod_rewrite); Deny (403, F flag in mod_rewrite). I don't have one for temporary redirects, because it's not common to have to replace a whole bunch of them at once. Oh, and if your existing rules say Redirect Permanent rather than Redirect 301 (the two wordings are interchangeable), change the pattern accordingly.
8:38 am on Mar 10, 2018 (gmt 0)

New User

joined:Dec 20, 2017
posts: 37
votes: 0


Thanks lucy24.
I am trying to get someone in the hire section to do this, but i see no listing for apache.
Also no one replies there. Is there another heading for your skill?
(If you were there I'd message you about this)
Arturo
7:18 pm on Mar 10, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15027
votes: 665


Remember at the beginning when I said make a copy of your htaccess file? Save the copy, make changes, upload the changed version. If the site explodes, quickly replace the changed file with the unchanged original.
8:22 am on Mar 11, 2018 (gmt 0)

New User

joined:Dec 20, 2017
posts: 37
votes: 0


ok I backedup htaccess. Can i check with you I am using your coding correctly here:


Redirect 301 /designer-watches/ice/ /department/watches/
Redirect 301 /gifts-and-collectables/lolita/ /department/gifts/
Redirect 301 /gifts-and-collectables/$ /


^Redirect(?:Match)? 301 /(.+)
TO
RewriteRule \1 [R=301,L]

^Redirect(?:Match)? 410 /(.+)
TO
RewriteRule \1 - [G]

^Redirect(?:Match)? 403 /(.+)
TO
RewriteRule \1 - [F]

RewriteRule proddet\.asp http://www.example.com/department/gifts/willow-tree/ [R=301,L]
# BEGIN W3TC Browser Cache
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/bmp application/java application/msword application/vnd.ms-fontobject application/x-msdownload image/x-icon image/webp application/json application/vnd.ms-access application/vnd.ms-project application/x-font-otf application/vnd.ms-opentype application/vnd.oasis.opendocument.database application/vnd.oasis.opendocument.chart application/vnd.oasis.opendocument.formula application/vnd.oasis.opendocument.graphics application/vnd.oasis.opendocument.presentation application/vnd.oasis.opendocument.spreadsheet application/vnd.oasis.opendocument.text audio/ogg application/pdf application/vnd.ms-powerpoint image/svg+xml application/x-shockwave-flash image/tiff application/x-font-ttf application/vnd.ms-opentype audio/wav application/vnd.ms-write application/font-woff application/font-woff2 application/vnd.ms-excel
<IfModule mod_mime.c>
# DEFLATE by extension
AddOutputFilter DEFLATE js css htm html xml
</IfModule>
</IfModule>
<FilesMatch "\.(html|htm|rtf|rtx|svg|txt|xsd|xsl|xml|HTML|HTM|RTF|RTX|SVG|TXT|XSD|XSL|XML)$">
<IfModule mod_headers.c>
Header append Vary User-Agent env=!dont-vary
</IfModule>
</FilesMatch>
<FilesMatch "\.(bmp|class|doc|docx|eot|exe|ico|webp|json|mdb|mpp|otf|_otf|odb|odc|odf|odg|odp|ods|odt|ogg|pdf|pot|pps|ppt|pptx|svg|svgz|swf|tif|tiff|ttf|ttc|_ttf|wav|wri|woff|woff2|xla|xls|xlsx|xlt|xlw|BMP|CLASS|DOC|DOCX|EOT|EXE|ICO|WEBP|JSON|MDB|MPP|OTF|_OTF|ODB|ODC|ODF|ODG|ODP|ODS|ODT|OGG|PDF|POT|PPS|PPT|PPTX|SVG|SVGZ|SWF|TIF|TIFF|TTF|TTC|_TTF|WAV|WRI|WOFF|WOFF2|XLA|XLS|XLSX|XLT|XLW)$">
<IfModule mod_headers.c>
Header unset Last-Modified
</IfModule>
</FilesMatch>
# END W3TC Browser Cache
# BEGIN W3TC Page Cache core
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{HTTPS} =on
RewriteRule .* - [E=W3TC_SSL:_ssl]
RewriteCond %{SERVER_PORT} =443
RewriteRule .* - [E=W3TC_SSL:_ssl]
RewriteCond %{HTTP:X-Forwarded-Proto} =https [NC]
RewriteRule .* - [E=W3TC_SSL:_ssl]
RewriteCond %{HTTP:Accept-Encoding} gzip
RewriteRule .* - [E=W3TC_ENC:_gzip]
RewriteCond %{HTTP_COOKIE} w3tc_preview [NC]
RewriteRule .* - [E=W3TC_PREVIEW:_preview]
RewriteCond %{REQUEST_METHOD} !=POST
RewriteCond %{QUERY_STRING} =""
RewriteCond %{REQUEST_URI} \/$
RewriteCond %{HTTP_COOKIE} !(comment_author|wp\-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
RewriteCond "%{DOCUMENT_ROOT}/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
RewriteRule .* "/wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]
</IfModule>
# END W3TC Page Cache core
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress
2:06 pm on Mar 11, 2018 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:3909
votes: 223


The edits to change redirects to rewrites included the instruction to "fire up a text editor" for those edits, that isn't to be done by your server in the .htaccess file. The lines:
^Redirect(?:Match)? 301 /(.+)
TO
RewriteRule \1 [R=301,L]

^Redirect(?:Match)? 410 /(.+)
TO
RewriteRule \1 - [G]

^Redirect(?:Match)? 403 /(.+)
TO
RewriteRule \1 - [F]
should be used to convert the lines of redirects to rewrite rules via "find & replace" using a text editor that can use RegEx (regular expressions). Then the resulting text could replace the Redirect lines that are in the htaccess file. The purpose of using the text editor with RegEx is to save you the time and trouble of manually converting each line of Redirect to a RewriteRule.

For example, you would use
^Redirect(?:Match)? 403 /(.+)
to find, and
RewriteRule \1 - [F]
to replace and the text editor could replace every instance of your 403 redirects.

5:24 pm on Mar 11, 2018 (gmt 0)

New User

joined:Dec 20, 2017
posts: 37
votes: 0


ok , thanks
6:22 pm on Mar 11, 2018 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:3909
votes: 223


Run a trial first, if you are not sure about what regex engine your text editor uses. As lucy24 noted:
replace \1 with $1 depending on your RegEx engine

There are various versions of regex and yours might need "$1" rather than "\1" if it is not adding on the rule text after the 'replace' step.

If you are on a Windows computer, don't use the basic Notepad text editor. In Mac I use BBEdit or TextWrangler, in Windows I used Notepad++.
7:17 pm on Mar 11, 2018 (gmt 0)

New User

joined:Dec 20, 2017
posts: 37
votes: 0


I am using editplus

so just to make it easy for me to understand, here is an existng 301 and and existing 410 statement

Redirect 301 /designer-watches/ice/department/watches/
what does this become?


RedirectMatch 410 ^/jewellery-logo-2
what does this become ?

thanks
Arturo
8:06 pm on Mar 11, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15027
votes: 665


not2easy, thanks for translating my post into English. Oops. Now then....

Caution: All of this applies only to rules in htaccess or in a <Directory> section of config. Rules lying loose in config--most likely in a <VirtualHost> section--are a little different.

It has just occurred to me that opening anchors need special handling in the change from mod_alias to mod_rewrite, since the anchor--if any--comes before the leading / in mod_alias rules. Hence

^Redirect(?:Match)? 301 (\^)?/(.+)
TO
RewriteRule \1\2 [R=301,L]

^Redirect(?:Match)? 410 (\^)?/(.+)
TO
RewriteRule \1\2 - [G]

^Redirect(?:Match)? 403 (\^)?/(.+)
TO
RewriteRule \1\2 - [F]
Note the difference between ^ meaning “the beginning of the line you’re editing” and \^ meaning “the literal ^ character”.

:: scurrying off to change boilerplate before I forget ::

With these updates:

^Redirect(?:Match)? 301 (\^)?/(.+)
TO
RewriteRule \1\2 [R=301,L]
applied to
Redirect 301 /designer-watches/ice/department/watches/ http://www.example.com/new-url-here
changes it to
RewriteRule designer-watches/ice/department/watches/ http://www.example.com/new-url-here [R=301,L]

^Redirect(?:Match)? 410 (\^)?/(.+)
TO
RewriteRule \1\2 - [G]
applied to
RedirectMatch 410 ^/jewellery-logo-2
changes it to
RewriteRule ^jewellery-logo-2 - [G]

:: mopping brow ::

Edit: I'm assuming the “existing 301” was incomplete as quoted, since the target (what you're redirecting to) is missing.
12:38 am on Mar 12, 2018 (gmt 0)

New User

joined:Dec 20, 2017
posts: 37
votes: 0


Result is
RewriteRule designer-watches/ice/department/watches/ /department/gifts [R=301,L]
...crashes the site.

So I have to add the full url in this statemetn, right? i.e.
RewriteRule designer-watches/ice/department/watches/ https://example.com/department/gifts [R=301,L]
unlike the 410 rewrite where you only write part of the url?
4:04 am on Mar 12, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15027
votes: 665


Show me a sample of each of your existing Redirect rules, one for 301 and one for 410.
10:04 am on Mar 12, 2018 (gmt 0)

New User

joined:Dec 20, 2017
posts: 37
votes: 0


I did 40 of 301s and 4 of 410s manually and here are some samples
.
RewriteRule designer-jewellery/fredbennett/mens-jewellery-collection /department/jewellery/fred-bennett [R=301,L]
RewriteRule designer-jewellery/v-i-p/jewellery /department/jewellery/v-i-p [R=301,L]
RewriteRule gifts-and-collectables$ / [R=301,L]
RewriteRule gifts-and-collectables/disney-traditions/traditional-figures /department/gifts/disney-traditions [R=301,L]

Here are some 410's i did manually
RewriteRule ^jewellery-logo-2 - [G]
RewriteRule ^/accurist-new-logo - [G]
RewriteRule ^/fred-bennett-logo2 - [G]
RewriteRule https://example.com/shop/ - [G]
1:51 pm on Mar 12, 2018 (gmt 0)

Administrator from US 

WebmasterWorld Administrator not2easy is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Dec 27, 2006
posts:3909
votes: 223


I think lucy24 wanted to see examples of the original old Redirect versions of those rules, what you were using before any find/replace was done.

Are they the same as shown in your previous post above?
I have approx 40 urls with 301 statements such as
Redirect 301 /watches/ice/ /department/watches/
Redirect 301 /collectables/lolita/ /department/gifts/
They all work ok, no bad url.
3:06 pm on Mar 12, 2018 (gmt 0)

New User

joined:Dec 20, 2017
posts: 37
votes: 0


Here are examples of the very original 301 and 410 lines of code

RedirectMatch 410 ^/jewellery-logo-2
RedirectMatch 410 ^/accurist-new-logo

Redirect 301 /designer-jewellery/fredbennett/mens-jewellery-collection/ /department/jewellery/fred-bennett/
Redirect 301 /designer-jewellery/v-i-p/jewellery/ /department/jewellery/v-i-p/
Redirect 301 /gifts-and-collectables/$ /

Redirect 301 /designer-watches/ice https://example.com
Redirect 301 /gifts-and-collectables/lolita https://example.com
8:35 pm on Mar 12, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15027
votes: 665


Redirect 301 /designer-watches/ice https://example.com
Please do not do this. You clearly have a 410 in place for other files; do the same for these. Make sure you have a nice 410 page. Depending on individual circumstances, you may be able to use the same physical page you serve for a 404, but you still need a separate ErrorDocument directive.

RewriteRule ^/accurist-new-logo - [G]
One difference between mod_rewrite and mod_alias in an htaccess file (or in a <Directory> section of config) is that there is no leading slash. Ever. This will not produce a 500-class error; the rule simply won't execute. (Trivia: This applies even if there is a malformed URL with two consecutive slashes. For some reason, multiple directory slashes are only recognized in a RewriteCond. I don't know if the docs explain it anywhere; I learned it by experiment.)

Redirect 301 /gifts-and-collectables/$
This will not work as intended. The $ is an anchor, so the rule has to use RedirectMatch.

Redirect 301 /designer-jewellery/fredbennett/mens-jewellery-collection/ /department/jewellery/fred-bennett/
My find-and-replace rule assumes that your redirect target includes the full protocol-plus-domain. If it doesn't, you'll need to add it:
^Redirect(?:Match)? 301 (\^)?/(\S+) /(.*)
TO
RewriteRule \1\2 https://example.com/\3 [R=301,L]

This brings us up to three count 'em three separate captures. (Query: Why don't I simply capture the / for reuse? Answer: Personal coding style. I like having the / plainly visible between elements.)

And finally: Throughout, I've assumed that the redirects apply to individual pages. In mod_alias, paths are changed and the rest is added back on; in mod_rewrite you have to capture anything that's to be reused. If some of them involve paths, such as multiple pages in a single directory, you need to capture still more stuff, bringing us up to four captures.

Honestly, at this point it may be faster to do them by hand.
11:49 pm on Mar 12, 2018 (gmt 0)

New User

joined:Dec 20, 2017
posts: 37
votes: 0


Thanks fro all your help. I will get to work on all of this
1:36 am on Mar 13, 2018 (gmt 0)

Administrator

WebmasterWorld Administrator phranque is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Aug 10, 2004
posts:11393
votes: 157


Redirect 301 /designer-watches/ice https://example.com


Please do not do this. You clearly have a 410 in place for other files; do the same for these.

by "this" lucy24 means don't redirect requests for missing urls to the home page.
7:50 am on Mar 13, 2018 (gmt 0)

Senior Member from US 

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time 5+ Year Member Top Contributors Of The Month

joined:Apr 9, 2011
posts:15027
votes: 665


by "this" lucy24 means
Years ago I was active on a forum where site modifications typically went like this:
-- administrator makes changes, and explains them in forum-administrator-speak
-- I translate administrator-speak into something more nearly approximating English
-- a third person translates my words into English as the term is generally understood.
This 34 message thread spans 2 pages: 34