.htaccess problem using POST method
-
Hi guys
I'm after some help with trying to achieve the following:
1. Canonicalise to http://www.
2. Remove the index.php from root and subfolders.
I have the .htaccess code below, which seemed to work fine, but the urls use the POST method and this isn't working with the rewrites.
Can anyone please advise as to what I am doing wrong? As you can probably guess .htaccess isn't my strongest SEO discipline!
The code I have is:
http:// to http://www.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomainexample.com
RewriteRule (.*) http://www.mydomainexample.com/$1 [R=301,L]/index.php to /
Options +FollowSymLinks
DirectoryIndex index.phpRewriteCond %{THE_REQUEST} ^[A-Z]{3,9}\ /index.php\ HTTP/
RewriteRule ^index.php$ http://www.mydomainexample.com/ [R=301,L]Subdirectory /index.php to /
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /([^/]+/)index.(php|html|htm?)[#?]?
RewriteRule ^(([^/]+/))index.(php|html|htm?)$ http://www.mydomainexample.com/$1 [R=301,L]Just to add to this I have found this which I think is what I need to restrict it to GET:
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,L] Thank you in advance for any suggestions as to how I may put this code together..
Trevor
-
Hi Keri
Thanks for the thumbs up
Must be a lot of people out there with the same question; the post on this topic, on my site, gets a lot of visitors.
Thanks again.
-
I gave you a thumbs up! Glad you solved this, and I'm sure it'll help someone in the future. Thanks for posting the answer!
-
Hi guys
Not sure if I can get mozpoints for answering my own question - perhaps someone can thumb it up
Anyway below is the .htaccess code that seems to work for canonicalization and allowing POST:
http:// to http://www.
RewriteEngine on
RewriteCond %{HTTP_HOST} ^mydomainexample.com
RewriteRule (.*) http://www.mydomainexample.com/$1 [R=301,L]REDIRECT /folder/index.php to /folder/
RewriteCond %{THE_REQUEST} ^GET.index.php\ HTTP/
RewriteRule ^(([^/]+/))index.php$ http://www.mydomainexample.com/$1 [R=301,L]Cheers
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
In writing the url, it is better to use the language used by the people of my country or English?
We speak Persian and all people search in Persian on Google. But I read in some sources that the url should be in English. Please tell me which language to use for url writing?
Technical SEO | | ghesta
For example, I brought down two models: 1fb0e134-10dc-4737-904f-bfdf07143a98-image.png https://ghesta.ir/blog/how-to-become-rich/
2)https://ghesta.ir/blog/چگونه-پولدار-شویم/0 -
Canonical homepage link uses trailing slash while default homepage uses no trailing slash, will this be an issue?
Hello, 1st off, let me explain my client in this case uses BigCommerce, and I don't have access to the backend like most other situations. So I have to rely on BG to handle certain issues. I'm curious if there is much of a difference using domain.com/ as the canonical url while BG currently is redirecting our domain to domain.com. I've been using domain.com/ consistently for the last 6 months, and since we switches stores on Friday, this issue has popped up and has me a bit worried that we'll loose somehow via link juice or overall indexing since this could confuse crawlers. Now some say that the domain url is fine using / or not, as per - https://moz.com/community/q/trailing-slash-and-rel-canonical But I also wanted to see what you all felt about this. What says you?
Technical SEO | | Deacyde0 -
Htaccess mod rewrite from server address
Hi there, I'm not massively experienced with creating mod rewrite rules and I'm worried I've got this wrong as its slightly different to what I'm used to. The web dev and content creators were working on http://5.10.105.45/~isea/ to create content. I want to redirect all URL's to www.iseasurfwear.co.uk. This is what I've written //Rewrite to www
Technical SEO | | BlueTree_Sean
Options +FollowSymLinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^5.10.105.45/~isea/[nc]
RewriteRule ^(.*)$ http://www.iseasurfwear.co.uk/$1 [r=301,nc] Can anyone tell me if this is correct?0 -
I am looking for the best post and page title template
There seems to be a few schools of thought as to how the title templates in the yoast plugin. currently mine are set with the default templates posts title template (%%title%% %%page%% %%sep%% %%sitename%%) page title template (%%title%% %%page%% %%sep%% %%sitename%%) What are the best options here for proper SEO. I am learning as much as i can but i have searched for a concrete answer here on the net, but found many different responses. What do you all think? What is my best option?
Technical SEO | | donsilvernail0 -
Spam posts indexed, what to do now?
Hi, So we had a staff problem last week and we let some spam posts (cheap nike jerseys etc.) that also got indexed by Google. (We just checked and there are lik 105 already indexed) Of course we have now removed all these spam posts but what is the best practice at this point? Are we supposed to do something else to remove these from Google's index? (maybe through google webmaster tools?) We have already edited robots.txt to disallow those pages as a quick remedy. And finally, could this have done any harm? We were quite slow noticing these posts to remove them. They were there for about 12 days. thanks
Technical SEO | | Gamer070 -
Managed DNS potential SEO problems
Hi All, We have a multinational client that would like servers in different country's with localised language.The DNS will determine what server in which country to serve from Is there any SEO implications based on content duplication? Thanks Chris Byrnes
Technical SEO | | SEOBrisbane900 -
Wordpress Problems.. SEO-Yoast is Toast?
Hello; I have installed the WP Yoast Widget in my Blog, and 2 weeks, after my issues went away, they came back X's 300! lol So I uninstalled it, and my issues obviously got worse, and then I re-activated, and reset everything, and still got the 300+ issues. Is there a secondary plug in you would suggest, to run at the same time as Yoats, or theat will fix all issues? Ever think of making an SEOmoz Widget for WP since it is gaining so much popularity?? Thank you Great work by the way! Loved the Webinar today!
Technical SEO | | smstv0 -
Home Page Indexing Question/Problem
Hello Everyone, Background: I recently decided to change the preferred domain settings in WM Tools from the non www version of my site to the www version. I did this because there is a redirect from the non www to the www and I've built all of my internal links with the www. Everything I read on SEO Moz seemed to indicate that this was a good move. Traffic has been down/volatile but I think it's attributable mostly to a recent site change/redesign. Having said that the preferred domain change did seem to drop traffic an additional notch. I made the move two weeks ago. Here is the question: When I google my site, the home page shows up as the site title without the custom title tags I've written. The page that displays in the SERP is still the non www version of the site. a site:www.mysite.com search shows an internal page first but doesn't return the home page as a result. All other pages pop up indexed with the www version of the page. a site:mysite.com (notice lack of www) search DOES SHOW my home page and my custom title tags but with a non www version of the page. All other pages pop up indexed with the www version of the page. Any one have thoughts on this? Is this a classic example of waiting on Google to catch up with the changes to my tiny little site?
Technical SEO | | JSOC0