remove index.php in URLs for Worpress

ISAPI_Rewrite is a powerful URL manipulation engine based on regular expressions
User avatar
Posts: 14
Joined: 27 Apr 2013, 17:11

remove index.php in URLs for Worpress

21 Nov 2013, 09:36

Currently in Wordpress the URLs are working as follows:

http://mydomain.co.uk/index.php/category/

What im trying to achieve and failing is this:

http://mydomain.co.uk/category.html

Could someone please post a rule to do this?
(Using rewrite v2)

Thank you

User avatar
Posts: 14
Joined: 27 Apr 2013, 17:11

Re: remove index.php in URLs for Worpress

21 Nov 2013, 09:42

Or even just to remove the index.php from the URL would be fine (better in fact)

so the current URL:

http://mydomain.co.uk/index.php/category/

Would become this:

http://mydomain.co.uk/category/

Could someone please post a rule to do this?
(Using rewrite v2)

User avatar
Posts: 14
Joined: 27 Apr 2013, 17:11

Re: remove index.php in URLs for Worpress

21 Nov 2013, 10:10

im now half way there, ive got the rule to remove the www. from the URL as I wanted, and using the permalinks in wordpress ive got the website structure how I want:

http://mydomain.co.uk/category/


These are my current rules:

# RULE NAME: Redirect www to non-www
# (http://www.mydomain.co.uk to http://mydomain.co.uk)
[ISAPI_Rewrite]

RewriteCond Host: http://www.mydomain\.co.uk
RewriteRule (.*) http\://mydomain\.co.uk$1 [I,RP]

# clean up page urls

RewriteRule /(?!index\.php)([^.]+?)/? /index.php/$1 [I,L]



However one last problem, my website in Google is indexed using the old structure which still works (http://mydomain.co.uk/index.php/category/) So I need a 301 redirect (or equivalent permanent redirect) to point those URLs to the new urls (ie remove the index.php part) http://mydomain.co.uk/category/ so that I dont get problems with duplicate content.

Could someone please help with this final piece of the puzzle?
Thank you

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: remove index.php in URLs for Worpress

21 Nov 2013, 11:52

Try using:

Code: Select all
RewriteRule /index\.php/([^/]+)/? /$1 [I,R,L]


Regards
Andrew

User avatar
Posts: 14
Joined: 27 Apr 2013, 17:11

Re: remove index.php in URLs for Worpress

21 Nov 2013, 12:35

That has broken the website, none of the category pages will now load...

User avatar
Posts: 14
Joined: 27 Apr 2013, 17:11

Re: remove index.php in URLs for Worpress

21 Nov 2013, 13:50

ok ive realised that the problem partly lies with the wordpress permalinks.

To get the site links working, under Permalinks in Wordpress I needed to select custom structure: /index.php/%postname%/

So currently the links on the site are http://mydomain.co.uk/index.php/category/

My goal is still to have the urls working as http://mydomain.co.uk/category/

Does anyone have a working solution for this?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: remove index.php in URLs for Worpress

21 Nov 2013, 16:51

Here's some help to get a basic ides - http://www.helicontech.com/articles/isa ... wordpress/. It's for ISAPI_Rewrite3 though

Regards
Andrew

User avatar
Posts: 14
Joined: 27 Apr 2013, 17:11

Re: remove index.php in URLs for Worpress

21 Nov 2013, 17:35

Thanks, I did look at that, but it doesn't provide a way to do what im looking for....

Does anyone have any alternative solutions...?

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: remove index.php in URLs for Worpress

22 Nov 2013, 12:23

I was just saying that the idea is the same: 1. Change WP permalinks to SEO-friendly. 2. Adjust the rules.
The rule you're looking for should look like:

Code: Select all
a. rewrite SEO-friendly urls to point to index.php
b. redirect old links to a new format without index.php


Did I understand correctly that you changed the permalinks to /index.php/category instead of /category/?

User avatar
Posts: 14
Joined: 27 Apr 2013, 17:11

Re: remove index.php in URLs for Worpress

22 Nov 2013, 17:06

Yes when I removed index.php from the permalinks, the links on the website didnt work.

So now im back to the website using the following structure:

http://mydomain.co.uk/index.php/category/

im trying to get it to use:

http://mydomain.co.uk/category/

but im not sure how to do it.

User avatar
Posts: 1264
Joined: 07 Mar 2012, 10:16

Re: remove index.php in URLs for Worpress

25 Nov 2013, 10:40

There are many cases that you can take a look at here. e.g. http://www.helicontech.com/forum/14820- ... e_2-1.html

Regards
Andrew

Return to ISAPI_Rewrite 2.x

Who is online

Users browsing this forum: No registered users and 0 guests