.htaccess file – any help please?
-
Hello and thanks in advance of any help!
My question is one about modifying an existing .htaccess file (I didn’t code the existing one, it’s something I have inherited. Can anyone please help?
The EXISTING .htaccess file reads as follows:
Redirect 301 /example_page_1.html https://www.domain-name.com/?products=example-product-1
Redirect 301 /example_page_2.html https://www.domain-name.com/?products=example-product-2
Redirect 301 /example_page_3.html https://www.domain-name.com/?products=example-product-3and on and on and on and finishes:
Redirect 301 /example_page_500.html https://www.domain-name.com/?products=example-product-500
==========================================
That’s it. (Notice that all these redirects involve “products” and the pretty URL strings are:)https://www.domain-name.com/?products=xxxxxxxxxxxxxxx
==========================================
Okay, so much for the content of the existing .htaccess file.
I now need to add to it; or modify it in some manner so that I can redirect several hundred other pages which are in this format:
https://www.domain-name.com/?page_id=521
to the “Post Name” option. ie
https://www.domain-name.com/post-name/
This is because when I tweak the permalink settings (either via the standard link in the WP dashboard or via its counterpart in Yoast – all of the resulting “prettier” page links break. I also see the message in the WP Dashboard (or Yoast) advising:
“If your .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file.”
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ – [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>Question is (finally!) – should I simply paste the lump of code above into the existing .htaccess file, exactly as is? If so, do I paste it above, or below those 500 existing “301 Redirect” lines? Or doesn’t it matter? Possibly, by pasting that <IfModule mod_rewrite.c> code in to the files, I could then REMOVE those 500 other lines?
One other question – it’s related:
Should I use this version of the <IfModule mod_rewrite.c> code (includes the # BEGIN and #END tags – found that version elsewhere on the net)
# 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 WordPressThank you VERY much for any help you might be able to provide!
D
- The topic ‘.htaccess file – any help please?’ is closed to new replies.