I have the following htaccess code which redirects any URL containing ar,cl,co,ec,mx,pe or ve to the same URL but with es in it's place.
eg. www.website.com/co/page becomes www.website.com/es/page
<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteRule ^/?ar/(.*)$ /es/$1 [R,L]
RewriteRule ^/?cl/(.*)$ /es/$1 [R,L]
RewriteRule ^/?co/(.*)$ /es/$1 [R,L]
RewriteRule ^/?ec/(.*)$ /es/$1 [R,L]
RewriteRule ^/?mx/(.*)$ /es/$1 [R,L]
RewriteRule ^/?pe/(.*)$ /es/$1 [R,L]
RewriteRule ^/?ve/(.*)$ /es/$1 [R,L]
</IfModule>
This works fine on my development server, but not on the live site. Is there a setting somewhere that could prevent this code from running?
Related
I have dynamic website and I made product name (cafeteria-table) to show when the page runs like below :
https://example.com/subcategory/cafeteria-table
Now if I edit characters in this product name (cafeteria-table) like i mentioned below it should show 404 error since it's duplicate pretty url :
https://example.com/subcategory/cafeteria
the page shouldn't run but still i can see page with header and footer with blank page and this is affecting seo.
This is my Htaccess
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{THE_REQUEST} ^.*/index\.php
RewriteRule ^(.*)index.php$ /$1 [R=301,L]
RewriteEngine on
RewriteRule ^index.php$ index.php
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://example.com/$1 [R,L]
Redirect 301 /subcategory/cafe%20chairs https://example.com/subcategory/cafe-chairs
#RewriteCond %{REQUEST_FILENAME} !-f
#RewriteRule ^([^\.]+)$ $1.php [R,L]
#RewriteRule ^category/chairs$ category/index.php
RewriteRule ^category/.*$ category/index.php
RewriteRule ^subcategory/.*$ subcategory/index.php
RewriteRule ^products/.*$ products/index.php
RewriteRule ^products/.*/.*$ products/index.php
</IfModule>
Any help would be appreciated.
when browsing www.mywebsite.com/en or www.mywebsite.com/fr it works fine, if browsing with / at the end of any, it gives page cannot be found
i'm using the htaccess code below:
RewriteOptions inherit
RewriteEngine on
AddDefaultCharset UTF-8
Options -Indexes
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteRule ^fr$ index.php
RewriteRule ^en$ index_en.php
RewriteRule ^fr/(.*)$ $1.php
RewriteRule ^en/(.*)$ $1_en.php
Try replacing
RewriteRule ^fr$ index.php
RewriteRule ^en$ index_en.php
With
RewriteRule ^fr/?$ index.php
RewriteRule ^en/?$ index_en.php
I apply like this
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^Product/Category/([^/]*)$ /Product/index.php?category=$1 [L]
RewriteRule ^Pages/([^/]*)$ /Allpages/?Pages=$1 [L]
RewriteRule ^Products/([^/]*)$ /Product/ProductPage.php?product=$1 [L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
but, It shows www.example.com redirected you too many times.
Okay #ravi i have got your problem so please use this solution.
New Code :
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^Product/Category/([^/]*)$ /Product/index.php?category=$1 [L]
RewriteRule ^Pages/([^/]*)$ /Allpages/?Pages=$1 [L]
RewriteRule ^Products/([^/]*)$ /Product/ProductPage.php?product=$1 [L]
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI}
</IfModule>
Hi On our website we are facing a issue like when we enter url without www for eg. example.com/xyz in this case after redirect it is converting to www.example.com/?url=xyz but it should be redirect to simply like: www.example.com/xyz
So we are getting extra ?url= in URL
We have used code for redirect non www url to www in our htaccess file. Code for redirect in htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
We have also tried this code but not work:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
</IfModule>
Try placing your redirect rule before the routing rules:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
So I have a whole series of redirects in place for a bunch of pages I want redirected to their parent directory (e.g. /faq/question1/ -> /faq/), but it's very inflexible, as they're manually generated.
How can I set up a RegEx-fueled RewriteRule for this? I haven't been able to figure it out, and would dearly love some guidance. Here's the whole of my .htaccess, to avoid any conflicts (you can see the individual RewriteRules I have in place right now):
AddDefaultCharset utf-8
AddHandler php5-script .php
DirectoryIndex index.php
ErrorDocument 403 /errors/forbidden.html
ErrorDocument 500 /errors/internalerror.html
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} ^halftoneproductions.com
RewriteRule (.*) http://www.halftoneproductions.com/$1 [R=301,L]
# FAQ redirects
RewriteRule ^faq/how-much-does-it-cost-to-make-an-albummix-a-songetc /faq/ [R=301,L]
RewriteRule ^faq/im-a-singersongwriter-with-no-band-members-would-you-be-able-to-do-a-full-production-of-my-songs-with-session-musicians /faq/ [R=301,L]
RewriteRule ^faq/do-you-do-postsound-for-film-at-all /faq/ [R=301,L]
RewriteRule ^faq/i-have-a-home-studio-and-just-need-to-record-___-is-that-cool /faq/ [R=301,L]
RewriteRule ^faq/are-you-a-publishing-company /faq/ [R=301,L]
RewriteRule ^faq/do-you-need-any-interns-or-runners /faq/ [R=301,L]
RewriteRule ^faq/can-i-bring-my-own-producerengineer-to-a-session /faq/ [R=301,L]
RewriteRule ^faq/what-types-of-music-do-you-work-on /faq/ [R=301,L]
RewriteRule ^faq/do-you-work-with-languages-other-than-english /faq/ [R=301,L]
RewriteRule ^faq/do-you-guys-make-beats /faq/ [R=301,L]
RewriteRule ^faq/i-have-an-old-tape-reelcasetteminidiscetc-and-would-love-to-transfer-it-to-some-other-form-can-you-help-out /faq/ [R=301,L]
RewriteRule ^faq/i-have-my-own-producerengineeretc-and-just-need-help-working-out-a-budget-for-my-project-and-booking-studio-time-can-you-help-out /faq/ [R=301,L]
# Recent Work redirects
RewriteRule ^recent-work/josh-and-neal /recent-work/ [R=301,L]
RewriteRule ^recent-work/midnights-son /recent-work/ [R=301,L]
RewriteRule ^recent-work/bearkat /recent-work/ [R=301,L]
RewriteRule ^recent-work/madi-diaz /recent-work/ [R=301,L]
</IfModule>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
If you want to redirect all requests that’s URL paths have /faq/ as prefix, you can use this rule:
RewriteRule ^faq/. /faq/ [R=301,L]
The single . represents an arbitrary character. So every request that’s URL path starts with /faq/ that followed by at least one character is redirected to /faq/.