WordPress .htaccess not working for rewriterule - php

Can we rewrite WordPress page /ghij to show the contents of page /faq, when permalinks are already enabled?
My page is example.com?page_id=70&category=Footage. After enabling permalink it is showing example.com/video-category?category=Footage. I want it to look like example.com/category/Footage.
Any help in this will be appreciated.
Current .htaccess:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^page_id=([0-9]*)&category=(.*)$
RewriteRule ^(.*)$ /%1/%2? [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Works. And redirects from:
http://test.com/index.php?page_id=70&category=Footage
To:
http://test.com/70/Footage
UPDATED:
RewriteRule ^(.*)/(.*)$ /index.php?page_id=$1&category=$2 [L]
This rule Works and makes inner redirect (without url change) from:
http://test.com/70/Footage
To:
http://test.com/index.php?page_id=70&category=Footage

i hope the following plugin will help you more
http://wordpress.org/extend/plugins/permalink-editor/
please check this plugin it will rewrite the permalink as you want without any coding knowledge.

Related

SEO friendly URL parameters via .htaccess

I want to rewrite the URLs from:
https://www.example.com/bibliorafturi/?wpsolr_fq%5B0%5D=pa_culoare_str%3AAlbastru
to this:
https://www.example.com/bibliorafturi/Albastru
Another example:
https://www.example.com/bibliorafturi/?wpsolr_fq%5B0%5D=pa_culoare_str%3AAlbastru&wpsolr_fq%5B1%5D=pa_brand_str%3AESSELTE
to this
https://www.example.com/bibliorafturi/Albastru/?wpsolr_fq%5B1%5D=pa_brand_str%3AESSELTE
So I need only pa_culoare_str to be SEO friendly.
How can I do this with .htaccess?
UPDATE:
This is my .htaccess file now:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI} /(.*)/(.*)/(.*)/?$
RewriteRule ^ /%1?wpsolr_fq[%3]=pa_culoare_str:%2 [QSA,L]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Thank you!

When i use domain and page name its redirecting to another folder

This is the URL of my website http://www.harimaumalaysia.my/ when i access through this url i can see my website with out error.
but when i use this URL http://www.harimaumalaysia.my/index.php Its redirecting to this URL www.harimaumalaysia.my/demo1.
how come this is happening while using index.php I changed my website url in database and permalinks but it didn't solved my problem can anyone help me out of this here is my ht-access 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
Set rewrite rule for index file like below.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^(css|editor|editordocs|images|js|sysimgdocs)/.*$ - [PT]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>

HTACCESS Remove Slug Not Working

I have custom post type on my wordpress site. And it has slug "dizi"
so url's are like that now
site.com/dizi/mypost
i want to remove dizi slug so they will be
site.com/mypost
I tried lots of wordpress function and none of them work and then i try htaccess but it is not working also.
Here is my htacess file
Options +FollowSymLinks -MultiViews
# 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 ^dizi/(.*)$ /$1 [L,NC,R]
</IfModule>
# END WordPress
With this code i can't see any effect.I m sure there is url conflict because i just installed wordpress and i have only 1 post.
Change the order of the lines. /index should be the last, the special patterns should be caught before:
RewriteRule ^dizi/(.*)$ /$1 [L,NC,R]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

htaccess rewrite url rule

I'm new to htaccess and I need some help with a rewrite rule.
I wish to rewrite:
/all-accomodation/anything/ to: /portfolio-gallery/anything/
The 'anything' could be any slug.
One thing to note is that I have a page with a slug of 'all-accomodation' and when requested by itself shouldn't rewrite.
Here is my current 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
Thanks in advance,
Dave
You don't want to edit Wordpress's rewrite. Above that block, you can try:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^all-accomodation/(.+)(/?) /portfolio-gallery/$1$2 [L]
</IfModule>
This will 301 redirect all requests.

htaccess help in coexisting Codeigniter and Wordpress install

My intention here is to have a codeigniter app with a blog under the same domain. The admin for both should be separate.
The directory structure is this:
httpdocs/.htaccess
httpdocs/application/ <== CI installation
httpdocs/blog/ <== WP installation
httpdocs/blog/.htaccess
URLs would be like this:
mysite.com <== CI
mysite.com/tools <== CI
mysite.com/forum <== CI
mysite.com/blog <== WP
I followed this tutorial to set up and it worked nicely.
Both my codeigniter app and WP blog home page show exactly as they should, with correct URLs, styles etc.
I can also access mysite.com/blog/wp-admin normally for WP back end stuff.
My issue is when I try to access an actual blog post, for example:
mysite.com/blog/fiction/what-is-going-on/
When I do this, I get Codeigniter's 404 error page.
My root .htaccess (httpdocs/.htaccess) is this:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|robots\.txt|blog|assets)
RewriteRule ^(.*)$ index.php/$1 [L]
My blog .htaccess (httpdocs/blog/.htaccess) is this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
Any idea what I'm doing wrong? Will post more info if requested. Thanks in advance.
OK the solution is to use
CI .htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
and
WP .htaccess
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress
That did the trick. Now all pages show without a problem.
I generally use 2 sets of conditions on the CI .htaccess (one on the root folder)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^blog/(.*)$ blog/index.php [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
This will allow the processing of blog URLs first and then deal with the CI URLs. You need to be careful not to have any controllers or routes using the term blog in your application.
I would try three things in your Wordpress .htaccess (don't touch the CI one -- it looks correct):
First, try removing the forward slash from before your index.php:
# 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 that doesn't work, then instead, try setting the RewriteBase to /blog/:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /blog/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
</IfModule>
# END WordPress
Finally, if neither of those things work, you can try manually adding "/blog/" to your index.php line at the end:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /blog/index.php [L]
</IfModule>
# END WordPress

Categories