URL Rewrite syntax help

This might be an easy one for someone, if not don’t worry.

I have a URL rewrite that rewrites:

www.mysite.com/myfolder/index.php?myfieldvalue/

as

www.mysite.com/myfolder/myfieldvalue/

Which looks like:

Options +FollowSymLinks
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)/ index.php?GSG_URL=$1

However, I now need it to rewrite:

www.mysite.com/myfolder/index.php?myfieldvalue

as

www.mysite.com/myfieldvalue/

But can’t get anything I’ve tried to work.

My guess is you’ve got that rewrite rule in an htaccess file that lives under myfolder/. You’ll have to move that rewrite rule to the root.

Thanks Jeff.

So would I also need to move the page to the root as well?

I do think this might be one of those things were there are a few permutations, and its a case of getting them all in the right place at the right time!

ie, if I currently have a page

www.mysite.com/myfolder/index.php

That might show

www.mysite.com/myfolder/index.php?myfield=myfieldvalue

Which redirects to:

www.mysite.com/myfolder/myfieldvalue/

(By which I mean if you navigate to www.mysite.com/myfolder/myfieldvalue/ you see the page you would see at www.mysite.com/myfolder/index.php?myfield=myfieldvalue)

And has the .htaccess file inside the /myfolder/ folder.

Do you mean I need to move that to the root, and so

www.mysite.com/myfieldvalue/ will display what you would see at www.mysite.com/myfolder/myfieldvalue/ ?

I think I have this working now.

There is a WordPress blog on the site which confused the issue a little.

So I have the following .htaccess in the root folder:

Options -Indexes
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^([^/]*)/$ /lodges.php?GSG_URL=$1 [L]
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

And am able to correctly display

www.mysite.com/mypage.php?myfield=myfieldvalue

at

www.mysite.com/myfield/

It seemed to be working OK, but some of the blog posts were getting messed up - showing as mypage.php but with no data.

I think I have identified the issue being resolved by making sure the permalink of the blog article does not contain the / at the end of the URL.

i.e. if it does, the page gets messed up.

If it does no, the page is OK.

Think I have resolved this no - blog pages with a / at the end of the URL break.

But pages without the / at the end are OK.