+ Reply to Thread
Results 1 to 6 of 6




Like Tree4Likes
  • 1 Post By GeoffL
  • 1 Post By simplyamazing12
  • 1 Post By tsdesigns
  • 1 Post By GeoffL
  

Thread: mod rewrite: how to rewrite "/"?

      
  1. #1
    I'm New! GeoffL is on a distinguished road
    Join Date
    April 14, 2011
    Posts
    4
    Rep Power
    0
    Feedback Score
    0

    Default mod rewrite: how to rewrite "/"?

    I have the following .htaccess on my development server (Apache2 under Ubuntu 10.10):

    Options +FollowSymLinks
    Options +Indexes
    RewriteEngine On
    RewriteRule ^/$ master.php?url=index.html [L]
    RewriteRule ^(.+\.html)$ master.php?url=$1 [QSA,L]

    This works fine on my own server and redirects all requests for .html files and "/" to master.php with the appropriate filename passed on the querystring. However, when I uploaded it to my GoDaddy hosting account I got 404s for requests for .html files and the content of index.php for "/". I solved the 404 errors by adding "Options -Multiviews" and "RewriteBase /", but I still got the content of index.php instead of master.php?url=index.html for "/".

    Can anyone tell me what the first rewrite rule should be to redirect "/" to master.php?url=index.html?

    TIA,

    Geoff
    Steve likes this.

  2. #2
    Grand Masters simplyamazing12 will become famous soon enoughsimplyamazing12 will become famous soon enough
    Join Date
    May 6, 2010
    Posts
    593
    Rep Power
    3
    Feedback Score
    0

    Default Re: mod rewrite: how to rewrite "/"?

    My advice is to just use the cPanel protocols to build this redirect. It is a much faster option and you don't have to mess with all of these codes.
    It does it all "behind the scenes".
    Steve likes this.
    My Business: Chi Chi Floral [link soon!]

    Web hosting provided by: Myhosting.com

  3. #3
    Super Moderator tsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to beholdtsdesigns is a splendid one to behold tsdesigns's Avatar
    Join Date
    February 6, 2008
    Location
    Scotland
    Posts
    1,078
    Rep Power
    6
    Feedback Score
    0

    Default Re: mod rewrite: how to rewrite "/"?

    Your best not to use a redirect to change the directory index, instead use this:

    Code:
    DirectoryIndex master.php?url=index.html
    This will change the site so that when "/" is requested, master.php is retrieved. Not entirely sure if parameters work through this though, haven't checked but I don't see any reason they wouldn't.

    As for why the redirect rule isn't working. I'd check with your hosting that mod_rewrite is active on your account.

  4. #4
    I'm New! GeoffL is on a distinguished road
    Join Date
    April 14, 2011
    Posts
    4
    Rep Power
    0
    Feedback Score
    0

    Default Re: mod rewrite: how to rewrite "/"?

    Many thanks for the pointer to DirectoryIndex.

    Mod rewrite is definitely active because I'm using it successfully except for that call to "/". GoDaddy seem to have their own rules in place with a succession of default pages in priority order, and there are several with greater priority than 'index.html'. I've temporarily resolved the matter by providing a top-priority page (default.html) that uses a meta refresh to redirect to index.html, but that's not ideal.

    Hopefully,
    DirectoryIndex master.php?url=index.html
    will do the trick. If not, I should be able to rewrite master.php to return the required content for index.html in the case of no querystring.

    Again thanks,

    Geoff
    Steve likes this.

  5. #5
    I'm New! GeoffL is on a distinguished road
    Join Date
    April 14, 2011
    Posts
    4
    Rep Power
    0
    Feedback Score
    0

    Default Re: mod rewrite: how to rewrite "/"?

    Don't you just hate it when you've spent days searching the Internet in vain for the solution to a problem. All the information that searching returns tells you what you've already tried should have worked, but it doesn't. So you post a question on a forum hoping someone's been there when someone responds with GIYF

    For completeness, the problem in my case is that GoDaddy already use mod rewrite to provide rules that define the default document and their rules took precedence over my attempt to explicitly rewrite "/". Using DirectoryIndex to locally define the default document as suggested upthread seems to have done the trick.

  6. #6
    I'm New! netcreativemind is on a distinguished road
    Join Date
    June 18, 2008
    Location
    New Delhi, India
    Posts
    13
    Rep Power
    4
    Feedback Score
    0

    Default Re: mod rewrite: how to rewrite "/"?

    modrewrite is done through apache server.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Similar Threads

  1. Replies: 0
    Last Post: Mar 10th, 2011, 2:58 am
  2. url rewrite
    By sates52 in forum HTML & Website Design
    Replies: 1
    Last Post: Aug 29th, 2010, 10:28 pm
  3. URL Rewrite
    By xsnoboard in forum Google
    Replies: 3
    Last Post: Dec 19th, 2009, 6:46 am
  4. Selling my "Name" , "Location" , and Avatar @ NP
    By Hurley4540 in forum Link Sales
    Replies: 23
    Last Post: Sep 26th, 2008, 11:56 am

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
WebTalkForums
WebTalkForums
Recent Forum Threads