Go Back   CodingForums.com > :: Server side development > Apache configuration

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-22-2012, 12:06 AM   PM User | #1
Dubz
Regular Coder

 
Join Date: Sep 2011
Posts: 206
Thanks: 15
Thanked 5 Times in 5 Posts
Dubz has a little shameless behaviour in the past
Question 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 is offline   Reply With Quote
Old 05-24-2012, 02:47 AM   PM User | #2
Dubz
Regular Coder

 
Join Date: Sep 2011
Posts: 206
Thanks: 15
Thanked 5 Times in 5 Posts
Dubz has a little shameless behaviour in the past
*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.

Last edited by Dubz; 05-24-2012 at 03:19 AM..
Dubz is offline   Reply With Quote
Old 05-26-2012, 03:57 AM   PM User | #3
Dubz
Regular Coder

 
Join Date: Sep 2011
Posts: 206
Thanks: 15
Thanked 5 Times in 5 Posts
Dubz has a little shameless behaviour in the past
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)
Dubz is offline   Reply With Quote
Users who have thanked Dubz for this post:
prizegrand (06-29-2012)
Old 06-29-2012, 07:23 PM   PM User | #4
prizegrand
New Coder

 
Join Date: Dec 2011
Posts: 32
Thanks: 2
Thanked 0 Times in 0 Posts
prizegrand is an unknown quantity at this point
Thumbs up

thanks bro just what i needed to make my app seo friendly
prizegrand is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 03:04 PM.


Advertisement
Log in to turn off these ads.