HTACCESS Remove Slug Not Working - php

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]

Related

Needed htaccess rewrite to preserve migration to wordpress

I have a website with this kind of querystring:
http://www.example.com/index.php?action=show&id=4577
I am moving to wordpress with this blog format:
http://www.example.com/archives/4577
But i should preserve wordpress rewrite conditions
<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 solution worked for me (i realized by my own...):
RewriteCond %{QUERY_STRING} action=show&id=([0-9]+)$
RewriteRule .*$ /archives/%1? [NC,R,L]

Redirect to index with url that contains specific number

I have some problems with custom Wordpress htaccess file. I want to get simple redirection from all URLs containing numbers after domain, ex:
http://example.com/123 -> to http://example.com
And, my second problem is almost the same, but for 1 specific 4-letter URL, ex:
http://example.com/4554 -> to http://example.com/
but http://example.com/4555 (other 4-letter nubmer should fail)
I've already tried many things, for example:
RewriteRule ^[0-9]{3}$ http://example.com [R=301,L]
But it doesnt work.
Usual Wordpress 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
Many thanks for help.
You can use:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^(\d{3}|4554)/?$ / [R=301,L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

How to ignore a wordpress permalink and use the folder path instead

I have a wordpress site but want to have another microsite within one of the folders.
www.example.com = main site
www.example.com/shop = new site
However on the main site I have pretty permalinks turned on, how do I make an exception for just "shop". Below isnt working.
# 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
RewriteCond %{REQUEST_URI} ^/shop
RewriteRule . /shop/index.php [L]
After doing a bit more digging on rewrites and .htaccess this code worked in the end...
Its simply saying if the url is shop stop any more rewrites
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^shop\.php$ - [L]
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress

WordPress .htaccess not working for rewriterule

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.

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