First of all, I checked older questions on the topic but I can't get it to work still.
I basically want:
http://example.com/example/?test=3 to redirect to http://www.yahoo.com
I have:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /example/
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /example/index.php [L]
RewriteCond %{QUERY_STRING} ^test=3$ [NC]
RewriteRule ^/example/index\.php$ http://www.yahoo.com [L,R=301]
</IfModule>
Ah yeah, I forgot that I already declared rewrite base. So, it should have been:
RewriteRule ^/index\.php$ instead of RewriteRule ^/example/index\.php$
Solved.
Put these lines just below your RewriteBase line:
RewriteCond %{QUERY_STRING} ^test=3$ [NC]
RewriteRule ^example/(index\.php|)$ http://www.yahoo.com? [L,R=301,NC]
And comment out your 2 lines below Wordpress rules.
Related
I am trying to set 2 rules:
if I type http://www.mydomain.it/notizie/LeDelizieDiCasa, htaccess has to load http://www.mydomain.it/?rssfeed=LeDelizieDiCasa page
www.mydomain.it/categoria/Cucina htaccess has to load http://www.mydomain.it/?categoryfeed=Cucina
I tried:
RewriteCond %{REQUEST_URI} ^/?rssfeed=Cucina
RewriteCond %{HTTP_HOST} ^(www.)?mydomain.it$ [NC]
RewriteRule ^(.*)$ http://www.mydomain.it/categoria/Cucina [R,L]
but it doesn't work, and if I go to http://www.mydomain.it/categoria/Cucina I have error 404 returned.
Who can help me?
mycurrent .htaccess:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
#rule 1
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.it$ [NC]
RewriteRule ^notizie/([^/]+)$ /?rssfeed=$1 [L]
#rule 2
RewriteCond %{HTTP_HOST} ^(www\.)?mydomain\.it$ [NC]
RewriteRule ^categoria/([^/]+)$ /?categoryfeed=$1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Thank you so much
It's difficult to help you, because I don't see your question or your problem...
I don't know why you add the www. or not.
1) Redirect notizie/LeDelizieDiCasa to http://www.mydomain.it/?rssfeed=LeDelizieDiCasa with:
RewriteRule notizie/LeDelizieDiCasa/? http://www.mydomain.it/?rssfeed=LeDelizieDiCasa [NC,L]
2) Redirect /categoria/Cucina to http://mydomain.it/?categoryfeed=Cucina:
RewriteRule categoria/Cucina/? http://www.mydomain.it/?rssfeed=LeDelizieDiCasa [NC,L]
Add that before #rule 1.
Ask, if it's not that...
I have a plugin to set up permalinks on my site however it only works when lead by www in front of the address. All other site addresses function fine with our without the leading www. I've been playing around my htaccess file but can't figure out how to fix this. The first portion is generated by the plugin, while I inserted the last 2 lines. Any suggestions on how to fix this? The last condition on my file seems to be getting ignored by all the permalinks.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^permalinks_dispatcher\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /cms/plugins/permalinks_dispatcher.php [L]
RewriteCond %{HTTP_HOST} ^mydomain.com
RewriteRule (.*) http://www.mydomain.com/$1 [R=301,L]
</IfModule>
You only have to begin with your www-rule first
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
RewriteRule ^permalinks_dispatcher\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^.*$ /cms/plugins/permalinks_dispatcher.php [L]
</IfModule>
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 a wordpress site. Here is link to site. I want to redirect www.abc.com/?portfolios=letters to www.abc.com/?files=letters.
I tried editing in code, but din't worked.
Here is htaccess
Options +FollowSymLinks
RewriteEngine on
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteRule ^womackpi.com/?portfolio=(.+) womackpi.com/?files=$1 [NC]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
This should do:
RewriteRule ^abc.com/?portfolios=(.+) abc.com/?files=$1 [NC]
It works for me!
You will also need:
Options +FollowSymLinks
RewriteEngine on
Above the previous statement.
Query strings are not part of the URI that is used to match against the expression in RewriteRule..
Try replacing RewriteRule ^womackpi.com/?portfolio=(.+) womackpi.com/?files=$1 [NC] with:
RewriteCond %{HTTP_HOST} ^(www\.)?womackpi.com$ [NC]
RewriteCond %{QUERY_STRING} (^|&)portfolio=(.+)(&|$) [NC]
RewriteRule ^(.*)$ /$1?files=%2 [L]
Add an R inside the [L] brackets if you want to redirect the browser (changing the URL in the address bar).
I have a Wordpress installation that works and a htaccess-file:
# 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
Outside Wordpress I have created links like this:
http://www.test.com/butik/?my-url
I think it looks nice except for the "?". Is it simple to add something to my htaccess-file to remove it?
http://www.test.com/butik/my-url/ would be perfect. Does it matter if I run a file at the path http://www.test.com/butik/index.php? Would it collide?
If I'm understanding correctly, you can try the following:
RewriteCond %{REQUEST_URI} !index.php
RewriteCond %{QUERY_STRING} !^$
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule (.*) $1%1? [L]
So, given your example, $1 would be /butik/ and %1 would be my-url (captured from the RewriteCond) Also, the first RewriteCond should prevent any conflicts with index.php requests.
Hope this helps.