SEO Friendly WordPress URL’s on Namesco Zeus Servers

January 13, 2013

This blog was moved a while ago to a Namesco server and it has been an amazingly reliable service compared to the last one I had. Uptime has been 100% as far as I can tell, and the service is fast and easy to use.

However, one thing that was bothering me was not being able to change from the WordPress default URL’s because doing mod_rewrite through .htaccess doesn’t work on Zeus servers. YOu’ve got to use their rewrite.script to rewrite URL’s and I wasn’t sure where to start with that.

Last week, thanks to a comment from @andrewburnett on Twitter, I thought I would figure out how to solve the problem and get some friendly URL’s up there.

I tried a few different bits of code but this one was the one that worked, found in this WordPress forum post.

RULE_0_START:
# get the document root
map path into SCRATCH:DOCROOT from /
# initialize our variables
set SCRATCH:ORIG_URL = %{URL}
set SCRATCH:REQUEST_URI = %{URL}

# see if theres any queries in our URL
match URL into $ with ^(.*)\?(.*)$
if matched then
set SCRATCH:REQUEST_URI = $1
set SCRATCH:QUERY_STRING = $2
endif
RULE_0_END:

RULE_1_START:
# prepare to search for file, rewrite if its not found
set SCRATCH:REQUEST_FILENAME = %{SCRATCH:DOCROOT}
set SCRATCH:REQUEST_FILENAME . %{SCRATCH:REQUEST_URI}

# check to see if the file requested is an actual file or
# a directory with possibly an index.  don’t rewrite if so
look for file at %{SCRATCH:REQUEST_FILENAME}
if not exists then
look for dir at %{SCRATCH:REQUEST_FILENAME}
if not exists then
set URL = /index.php?q=%{SCRATCH:REQUEST_URI}
goto QSA_RULE_START
endif
endif

# if we made it here then its a file or dir and no rewrite
goto END
RULE_1_END:

QSA_RULE_START:
# append the query string if there was one originally
# the same as [QSA,L] for apache
match SCRATCH:ORIG_URL into % with \?(.*)$
if matched then
set URL = %{URL}&%{SCRATCH:QUERY_STRING}
endif
goto END
QSA_RULE_END:

The above goes in your file called rewrite.script in the root folder.

Once I did that I went to the WordPress settings > Permalinks and told it to do a custom structure permalink:

/%category%/%postname%/

The default permalink structures had went along the lines of /index.php/%category%/%postname%/ but this just wouldn’t work until I’d removed the index.php from the equation.

This might not work for everyone, but I just thought I’d relay the experience incase it can help someone out.

{ 16 comments }

Andrew Burnett January 23, 2013 at 6:16 pm

Many thanks for the shout Dave :)

Another guy I follow on Twitter saw this page and it helped him with his Zeus Server, the circle completes itself :)

Brian February 13, 2013 at 5:24 pm

Hey thanks for that Dave….after a wasted day waiting on my useless ISP, hours spent messing with my code and a load of frustration your page came to the rescue, I simply cut and paste your script and bingo Im back in the groove.

Thanks a lot :)

Brian

PS. remember not to use a text editor as it will leave a TXT on the end of your file PSPad is free and usefull. Thanks again

Michael Hart March 3, 2013 at 1:30 am

Hi Dave,

Thank you very much for sharing.

I have a question. If it’s possible, could you let me know which part of the rewrite would need to be modified if I have wordpress running within a subdirectory on my hosting?

Cheers,

Mike.

Dave March 3, 2013 at 9:08 am

Thanks for all the comments. @Michael Hart – I’m not exactly sure, but if I was going to edit it I would probably start with the line that says:
set URL = /index.php?q=%{SCRATCH:REQUEST_URI}
and change it to:
set URL = /directoryname/index.php?q=%{SCRATCH:REQUEST_URI}

But don’t quote me on that! ;-)

Gene Jensen April 21, 2013 at 9:33 pm

Thanks very much for this post – I’ve always wondered if this was possible, and with a quick Google search I found you!

Andrew April 22, 2013 at 11:10 am

Thanks for posting Dave. Worked a charm.

ADT Home Security May 10, 2013 at 2:21 am

Hey Dave,

To quote Andrew, I am that guy from Twitter. The circle is complete

Search engine ranking May 22, 2013 at 1:54 am

That’s a good worpress tip! Even thouhg I have nor problams with mod_rewrite on my server, you never know, your expereince may come in handy. Thanks for sharing

Antony

Dora May 25, 2013 at 8:54 pm

It worked great. Thanks for the post Dave.

Alan Wyatt May 29, 2013 at 5:14 pm

Thanks for this post, it solved my problem in seconds after spending hours yesterday trying to set up .htaccess file and searching the web for a solution. It does seem many people have problems with Pretty Permalinks, though the problem is made worse by the Zeus server.

Thanks to you and the original poster!

anne smith June 12, 2013 at 1:13 am

Thank you so much this has helped me a lot. After hours of spending and searching about which part of my rewrite should I modify now I know what exactly what to do.

My Article Network July 11, 2013 at 2:14 pm

the code was really helpful, i was trying all other sources for it… that to your blog! it has helpped me immensely
Vin

stephen July 12, 2013 at 9:29 pm

This is just exactly what I needed Great article. This has been one of my biggest headaches with Wordpress and Zeus. Thanks for the post.

Kevin Lam August 28, 2013 at 5:39 pm

I’m not on a Zues server, but I’m having the same issue. I have to update plugins manually by downloading the latest plugins and uploading them via FTP. Quite annoying.

Ravi v August 31, 2013 at 1:09 pm

Finally got the direct solutions with the detailed code thank you very much. Just need to copy paste the code with little attributes and tags changed, well can anyone say is this different from the mod re-write as mentioned by Antony, because i am little confused when it comes to coding part. Ones again thank you sharing this valuable tip with us.

Christian October 8, 2013 at 11:16 am

Have you had any other problems with namesco? .. I got permalinks working now thanks to the rewrite.scripte above, but I still have a problem where new content (posts/pages/users) never appears. I can see in the phpMyAdmin screens that some things (users) make it to the DB but posts/pages never do. I want something other than “welcome to your blog” on the screen! .. and yes I already nuked/wiped it several times and moved SQL servers.

Previous post:

Next post:

microsoft search engines