Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Sep 2011
    Posts
    416
    Thanks
    18
    Thanked 26 Times in 26 Posts

    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.

  • #2
    Regular Coder
    Join Date
    Sep 2011
    Posts
    416
    Thanks
    18
    Thanked 26 Times in 26 Posts
    *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.

  • #3
    Regular Coder
    Join Date
    Sep 2011
    Posts
    416
    Thanks
    18
    Thanked 26 Times in 26 Posts
    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)

  • Users who have thanked Dubz for this post:

    prizegrand (06-29-2012)

  • #4
    New Coder
    Join Date
    Dec 2011
    Posts
    34
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs up

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •