CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Apache configuration (http://www.codingforums.com/forumdisplay.php?f=69)
-   -   Need help with .htaccess (http://www.codingforums.com/showthread.php?t=262125)

Dubz 05-22-2012 12:06 AM

Need help with .htaccess
 
I have a .htaccess in the root of my public_html site, but I need some assistance with it. What it's set to do is use this as the "fake link": 'http://website.com/home', but have it really show this: 'http://website.com/request.php?req=home'.
The URL shows the first link and uses the second basically.
Here is the .htaccess file:
Code:

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ request.php?req=$1 [NC,L]
DirectoryIndex request.php?req=home

The problem is the DirectoryIndex. Whenever i go to website.com it should go to the home by default, but it just shows the file index (allowing the user to see all the files in the public_html folder).

One other problem is I have a forum running on a subdomain (http://forum.website.com) and it does the same thing because of the .htaccess file in the parent folder, so I need the file t ignore folder 'forum'.

I found this on Google and tried it but it didn't seem to work:
Code:

=========[ start of .htaccess snippet]==========
<IfModule mod_rewrite.c>
  RewriteEngine on
  #
  # stuff to let through (ignore)
  RewriteCond %{REQUEST_URI} "/folder1/" [OR]
  RewriteCond %{REQUEST_URI} "/folder2/"
  RewriteRule (.*) $1 [L]
  #
====================[ end ]=====================

How I added it:
Code:

RewriteEngine On
RewriteCond %{REQUEST_URI} "/forum/"
RewriteRule (.*) $1 [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ request.php?req=$1 [NC,L]
DirectoryIndex request.php?req=home

Any assistance is appreciated! Also, the original .htaccess worked when my friend used it on his site so I think it may be a problem with the webhost or something else.

Dubz 05-24-2012 02:47 AM

*UPDATE*
I got the folder working and the subdomain to redirect, but I need the DefaultIndex to work only when its not that folder or the forum. Any help?

Edit:
I believe I have narrowed it down to what I need. I need a condition for DirectoryIndex as follows:

If the website is any of these ignore the default:
http://website.co.cc/Dubz
http://website.co.cc/forum
http://forum.website.co.cc/ (basically same as above, but the subdomain version)

otherwise, do this as the default:
http://website.co.cc/request.php?req=home


Edit:
Changed DirectoryIndex to this:
DirectoryIndex index.php http://website.co.cc/request.php?req=home

This way it will use the forum's first, then the main folders (basically) But he second one still won't work for some reason. I don't know if its the webhost blocking it or what but I need it fixed asap. If I can't get it I'll most likely make an index.html with a meta refresh redirect.

Dubz 05-26-2012 03:57 AM

Problem solved as follows:
DirectoryIndex request.php index.php

Modded the request.php to work (Just added a @ to not return an error when getting a value from the $_GET)

prizegrand 06-29-2012 07:23 PM

thanks bro :) just what i needed to make my app seo friendly


All times are GMT +1. The time now is 06:14 AM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.