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 }
Many thanks for the shout Adam
Another guy I follow on Twitter saw this page and it helped him with his Zeus Server, the circle completes itself
Hey thanks for that Adam….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
Hi Adam,
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.
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!
Thanks very much for this post – I’ve always wondered if this was possible, and with a quick Google search I found you!
Thanks for posting Adam. Worked a charm.
Hey Adam,
To quote Andrew, I am that guy from Twitter. The circle is complete
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
It worked great. Thanks for the post Adam.
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!
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.
the code was really helpful, i was trying all other sources for it… that to your blog! it has helpped me immensely
Vin
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.
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.
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.
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.