I've to change this url : http://localhost:8888/finance/schedule/?location=new_york
to http://localhost:8888/finance/schedule/location/new_york
It's a wordpress site, my htaccess code is :
RewriteRule ^schedule/location/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)\$ schedule/?location=$1
But nothing seems to happen, please suggest.
The whole htaccess file code:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /finance/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /finance/index.php [L]
RewriteRule ^schedule/location/([a-zA-Z0-9_-]+)/([a-zA-Z0-9_-]+)\$ schedule/?location=$1
</IfModule>
This line is stopping it from ever reaching your later rule:
RewriteRule . /finance/index.php [L]
The [L] means "last," as in "this is the last rule to run if it matches."
And \$ looks for a literal $, not the end of the string.
You also have two many matching groups in your rule.
You need something like this, instead (totally untested):
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /finance/
RewriteRule ^index\.php$ - [L]
RewriteRule ^schedule/location/([a-zA-Z0-9_-]+?)/?$ /wp-content/themes/financeinstitute/page_schedule.php/?location=$1
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /finance/index.php [L,QSA]
</IfModule>
Related
I have to redirect some url .
for example if the url is
www.example.com/shop valid
www.example.com/shop/red-product need redirection to www.example.com/red-product
www.example.com/shop/green need redirection to www.example.com/green
www.example.com/shop/any-string need redirection to www.example.com/any-string
How i can do this . Please help .
My current htacess file is
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Redirect 301 /bio/ https://www.example.com/bio/
Options -Indexes
You may replace your code with this one:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^shop/(.+)$ /$1 [L,NC,NE,R=301]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Below rule should work we are matching the group after shop only.
RewriteEngine On
RewriteCond %{REQUEST_URI} ^/shop/(.*)
RewriteRule ^ http://www.example.com/%1 [R]
I have this rewrite rule in .htaccess:
RewriteRule ^^babysitter/([^/]*)/([0-9]+)/? /hlp/index.php/babysitter/$1/?p=$2 [QSA,L]
So if I write this URL:
localhost/hlp/babysitter/rome/3618
the browser rewrites it like this:
localhost/hlp/babysitter/3618
which is something I don't want, even if it returns correct result.
For completeness I write my whole .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /hlp/
RewriteRule ^index\.php$ - [L]
RewriteRule ^^babysitters/([^/]*)/? /hlp/index.php/babysitters/?resume_location=$1 [QSA,L]
RewriteRule ^^babysitter/([^/]*)/([0-9]+)/? /hlp/index.php/babysitter/$1/?p=$2 [QSA,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /hlp/index.php [L]
</IfModule>
I try to rewrite all languages to /en/ on a site. But I do something wrong and do not know what.
All domain request like https://www.shop.com/de/ or https://www.shop.com/ must rewrite to https://www.shop.com/en/
Why I need this? First my shop must be ready in /en/ language. When everything works fine I will add /de/ and then /nl/.
Does someone have a solution for me? Would be very nice.
Here the code I use in htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule https://www.shop.com/de/ https://www.shop.com/en/
RewriteRule https://www.shop.com/nl/ https://www.shop.com/en/
RewriteRule https://www.shop.com https://www.shop.com/en/
RewriteRule https://www.shop.com/ https://www.shop.com/en/
</IfModule>
You cannot match full URLs in RewriteRule.
You can use these rules:
RewriteEngine On
RewriteBase /
RewriteRule ^(de|nl)?/?$ /en/ [L,NC,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
How can I change my URL from domain.com/sprekers/?spreker=value to domain.com/value with a rewrite rule with wordpress.
I've tried to change it like this
RewriteCond %{QUERY_STRING} ^spreker=(.*)$
RewriteRule ^sprekers/$ %1/? [R=301,L]
than I tested it with the htaccess tester http://htaccess.madewithlove.be If I test it on the tester everything works fine but when I do this on my wordpress site it doesn't work. This is my complete 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]
RewriteCond %{QUERY_STRING} ^spreker=(.*)$
RewriteRule ^sprekers/$ %1/? [R=301,L]
</IfModule>
I think it doesn't work because the /sprekers is already "made" by wordpress how can I fix this?
Cheers
Robin
I think, you need to put your first code after the RewriteBase / rule.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^spreker=(.*)$
RewriteRule ^sprekers/$ %1/? [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
I have couple of urls which is generated by wordpress/php
http://mydomain.com/news-2/newsarticle
http://mydomain.com/products/category-2
http://mydomain.com/products/category/products-2
how can I rewrite/redirect any url with -2 to the one without? The result should be
http://mydomain.com/news/newsarticle
http://mydomain.com/products/category
http://mydomain.com/products/category/products
This is what I have so far
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Thanks
Add this to you htaccess :
RewriteRule ^(.*)-2(.*)$ /$1$2 [NC,L,R=301]