sazr
sazr

Reputation: 25938

Server File Configuration: Using .htaccess to redirect to a script but pass CGI arguments aswell

I have an idea that will allow a Web Forums Content/Threads to be better indexed by search engines but avoid taking up too much unnecessary space on the web server.

My idea is not unique(I think StackOverflow uses it) but I am having difficulty working out how I am going to achieve redirecting through .htaccess commands or main server configuration files.

For a web forum website; when a new thread is created:

My Questions:

Maybe the code would look something like this?

Redirect /posts/* www.myForum.com/cgi-bin/loadWebpage.py?thread="HOW DO I SPECIFY THE FOLDER?"

Upvotes: 2

Views: 387

Answers (1)

Ulrich Palha
Ulrich Palha

Reputation: 9539

If I am using a webhost like GoDaddy do I have access to this file or is this server config file only for VPS?

Godaddy shared hosting only allows .htaccess use.

Is it better to do this with the Server Config file instead?

Its better performing if you have access to Server Config, but shared hosting like Godaddy does not allow it.

Do I NOT need to create a .htaccess file in each post directory? Can I just write in my main .htaccess file that any request to a file/folder in posts should redirect to www.myForum.com/cgi-bin/loadWebpage.py?thread=the directory they accessed?

You can do it with a single .htaccess in the root dir of your site with contents as below

RewriteEngine on
RewriteBase /

RewriteRule ^posts/(.+)/$ /cgi-bin/loadWebpage.py?thread=$1 [NC,L]

Upvotes: 2

Related Questions