Gossamer Forum
Quote Reply
mod rewrite headache
Going daft, trying to do a mod rewrite in htaccess to make my dynamic links site into static, tried the various solutions here in the forums but having no luck, can anyone help, its the latest release of lsql.
Quote Reply
Re: [roman365] mod rewrite headache In reply to
We use a very simple formula.

Our links sites are the main page of our site. (eg: home.html is our "index.html")

The key to making it work, is you need an EMPTY directory, to redirect your links from.

So, lets say you could live with the link:


Make an _EMPTY_ directory called "links"

Then, in the .htaccess (we do this in the server config, but it should work via .htaccess) for the root directory you put in:

RewriteEngine On
RewriteRule ^/$ /links/
RewriteRule ^/links/?$ /links/

That turns on the Rewrite engine, and defines the re-mapping relationship.

Then, in the "links" directory, you add to the .htaccess file

<Directory /path/to/links/directory/links>
Options All -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
RewriteEngine On
RewriteRule (.*) /cgi-bin/LinksSQL/page.cgi?g=$1 [L]
AllowOverride All
Allow From All

You might have to experiment to see how you add that. I am not sure you can add that to the root .htaccess, and if you add it to the links/.htaccess file, you probably don't need the <directory> tags. (and of course change your path to the page.cgi file)

We put them in the server config, and it works. I prefer that, but if you don't have a dedicated server, you are stuck with .htaccess files.

The idea, is the .htaccess commands in the root .htaccess redirect the request to the /links directory, which takes the request, and remaps it to the RewriteRule by sending the request to page.cgi.

PUGDOG´┐Ż Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] mod rewrite headache In reply to

I tried this on my site, and the only way I could get it to work was by removing the highlighted slash;

RewriteEngine On
RewriteRule ^/$ /links/
RewriteRule ^/links/?$ /links/

Removing the second line entirely didn't change anything but I still have problems navigating home in the menu bar link.

Any suggestions where I'm going wrong, or is this OK?


Quote Reply
Re: [Piers1] mod rewrite headache In reply to

RewriteRule ^/?$ /links/

Hope that helps.


Andy (mod)
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] mod rewrite headache In reply to
Lovely - that did it.