I am trying to setup a query redirect for my category pages
Currently the url is as follows:
http://chunkydeals.com/daily-deals/?category=alldeals
I am trying to get it to be something like:
http://chunkydeals.com/daily-deals/alldeals/
my htaccess code is as follows:
# 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]
RewriteCond %{QUERY_STRING} ^category=([a-z])*)$
RewriteRule ^daily-deals/$ http://chunkydeals.com/daily-deals/%3/? [R=301,L]
</IfModule>
# END WordPress
Any help would be appreciated
Have you tried putting the QUERY_STRING rules above the one that rewrites to index.php? (which prevents the regex ^daily-deals/$ from matching)
RewriteBase /
RewriteCond %{QUERY_STRING} ^category=([a-z])*)$
RewriteRule ^daily-deals/$ http://chunkydeals.com/daily-deals/%1/? [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
Related
I would like to redirect path like this
http://www.example.com/uploads/2017/10/image.ext/version/?id=87988984632
to
http://www.example.com/uploads/2017/10/image.ext
where extension could be whatever image or video extension.
I'm can detect the last part with this \/version\/(.*)$ but I can't remove from the uri.
Update:
This is my .htaccess and I'm using Wordpress
# 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]
RewriteRule \/version\/(.*)$
</IfModule>
Thanks for your help
You can use this new redirect before other WP rules:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.+)/version/?$ /$1? [L,NC,NE,R=301]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
How do you redirect a directory (in this case /resume/) to a file (/Resume.pdf) using an .htaccess file? I have tried different rewrite methods but keep getting a redirect loop. Is this because of a conflict with WordPress?
This doesn't seem to work:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^resume/ http://domain.com/Resume.pdf [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Ok, I figured it out and here's what I got to work:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/resume$ [NC]
RewriteRule ^(.*)$ http://domain.com/Resume.pdf [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I am trying to serve a specific jpeg picture that depends on the directory.
For example:
/i/t/150/63211.jpg => /i/404/150.jpg
/i/t/195/63211.jpg =>/i/404/195.jpg
At the moment, even something simple (one rule at a time) like :
RewriteCond %{REQUEST_URI} ^/i/t/150/.*\.jpg
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^.*$ /i/404/150.jpg [L]
Doesn't work even if my jpeg file is in the directory /i/404/.
I think the problem comes from the fact that /i/ is a symlink.
My goal is to have the 2 rules (for 150.jpg/195.jpg) in the same RewriteRule. But let's try to make it work with one only.
Here is my full htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(.*)-a([0-9]+)\.html$ 301oldninapeople.php?oldid=$2§ion=news [L]
RewriteRule ^(.*)-n([0-9]+)\.html$ 301oldninapeople.php?oldid=$2§ion=theme [L]
RewriteRule ^(.*)-n([0-9]+)-page([0-9]+)\.htm$ 301oldninapeople.php?oldid=$2§ion=theme [L]
RewriteRule ^301oldninapeople\.php$ - [PT,L]
RewriteCond %{REQUEST_URI} ^/i/t/150/.*\.jpg
RewriteCond %{REQUEST_URI} !-f
RewriteRule ^.*$ /i/404/150.jpg [L]
RedirectMatch 301 ^/rss/news.(xml|asp)$ /feed
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# 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
Current robots.txt after the first answer:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^i/t/([^/]+)/.+?\.jpg$ /i/404/$1.jpg [L,NC,R]
RewriteRule ^(.*)-a([0-9]+)\.html$ 301oldninapeople.php?oldid=$2§ion=news [L]
RewriteRule ^(.*)-n([0-9]+)\.html$ 301oldninapeople.php?oldid=$2§ion=theme [L]
RewriteRule ^(.*)-n([0-9]+)-page([0-9]+)\.htm$ 301oldninapeople.php?oldid=$2§ion=theme [L]
RewriteRule ^301oldninapeople\.php$ - [PT,L]
RedirectMatch 301 ^/rss/news.(xml|asp)$ /feed
# RedirectMatch 301 ^/rss/news.xml$ /feed
# RedirectMatch 301 ^/rss/news.asp$ /feed
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# 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
You just need this rule:
RewriteCond %{DOCUMENT_ROOT}/$0 -f
RewriteRule ^i/t/([^/]+)/.+?\.jpg$ /i/404/$1.jpg [L,NC]
Also make sure to move this rule as first rule just below RewriteBase / line.
I need to redirect page1 to something/page1 in my wordpress site.
i have tried the below rule in my htaccess file.
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^page1/$ something/page1? [L]
</IfModule>
# END WordPress
i am not familiar in htaccess rules. but the redirection is not working.
can any one help me?
Thanks
Maybe this will work:
# BEGIN WordPress
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
# Next line added
RewriteCond %{REQUEST_URI} !page1 [NC]
RewriteRule . /index.php [L]
# Next 3 lines added
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^page1 something/page1? [L]
</IfModule>
# END WordPress
For permanent and visible redirection, replace [L] with [R=301,L] in the last rewrite rule.
My main domain is a Wordpress blog, and the .htaccess rewrite for it is as follows...
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
This works great, but I have a subdomain in that same directory, and am using this rewrite for it....
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{HTTP_HOST} ^my\.domain\.com$ [NC]
RewriteCond %{REQUEST_URI} !^/my/
RewriteRule ^(.*) /my/$1
That's for my wildcard SSL certificate. This works great, but if the location doesn't exist in the subdomain I get wordpress's error page. I need the wordpress rewrite to ignore the "my" subdomain. How can I do that?
I was thinking something like....
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^my\.domain\.com$
RewriteRule . /index.php [L]
</IfModule>
But that doesn't work, also tried this....
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^my\.domain\.com - [L,NC]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Any ideas?
You should probably ignore the domain by adding a condition on the server name.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{SERVER_NAME} !^my\.domain\.com
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Also, a thing I struggled with some time ago, try changing the htaccess of the subdomain to
RewriteBase /my
if "my" would be the directory it lives in.