SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Sep 2011
    Location
    Chicago
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    rewrite with variable lost on local virtual host test, but not on live server

    I have a local virtual host site setup where I'm using an .htaccess file to rewrite and I'm having this weird issue when the pretty url (followed by the variable I want to pass through) is the same as my source php file the variable does not get sent. But when I upload to the live server everything is fine.

    Is there some setting in my Virtual Host setup that missing that my live server hosting might have? I'd like to keep my pretty url the same as my source.php file and be able to test locally.

    Here's my .htaccess:
    Code:
    Options +FollowSymLinks
    RewriteEngine On
    RewriteCond %{SCRIPT_FILENAME} !-d
    RewriteCond %{SCRIPT_FILENAME} !-f
    RewriteRule ^about/(.*)$ /about.php?my_var=$1
    Then in my about.php file I have:
    PHP Code:
    <?php
    if (isset($_GET['my_var'])) {
        
    $my_var $_GET['my_var'];
        echo 
    'hello test: ' urldecode($my_var);
    }
    ?>
    Locally, I get the about.php page as the source, but the 'if' doesn't fire. When I use anything else in the pretty url, like 'bout' or 'who' everything works... source page is called for pretty url with the var passed through.

    On the Live server (MT), I get the 'if' statement fired off just fine, with my variable passed through to my page.
    Here's my live test with the pretty-url.


    Here's my v-host on my OS X
    Code:
    # ----------------------------------
    # PRETTY-URLS.COM
    <VirtualHost *:80>
      ServerName dev.pretty-urls.com 
    	DocumentRoot "/Users/kaplan/Sites/pretty-urls.com"
    	<Directory "/Users/kaplan/Sites/pretty-urls.com/">
    	Options Indexes Multiviews FollowSymLinks
    	AllowOverride All
    	Order allow,deny
    	Allow from all
    	</Directory>
    </VirtualHost>
    # ----------------------------------
    Any ideas on fixing my local Virtual host so that it will keep that variable and use the same name pretty-url vs source?
    Just when I thought I was getting the hang of mod_rewrite :-)

  2. #2
    SitePoint Member
    Join Date
    Sep 2011
    Location
    Chicago
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've found some fixes, but still a little confused. I believe it has to do with FollowSymLinks and my local vhost settings... definitely need to do more reading on the FollowSymLinks.

    So if in my original settings where vhosts has:
    Code:
    Options Indexes Multiviews FollowSymLinks
    # htaccess file I have:
    Options +FollowSymLinks
    1st fix: my rewrite needs to have about.php/ instead of about/:
    Code:
    RewriteRule ^about.php/(.*)$ /about.php?my_var=$1
    Or 2nd fix: I can remove the plus in the .htaccess on the FollowSymLink and leave the about/ and it works
    Code:
    Options FollowSymLinks 
    RewriteRule ^about/(.*)$ /about.php?my_var=$1
    Or 3rd approach: in my vhosts I can use:
    Code:
    Options -Indexes -Multiviews +FollowSymLinks
    Then in my .htaccess use FollowSymLinks without the '+' or not use it all (locally anyway) maybe because of my vhost setting... that could be different on the live server I guess. I have a feeling leaving it on and making the change to my vhost is the best approach.
    Code:
    #Options FollowSymLinks 
    RewriteRule ^about/(.*)$ /about.php?my_var=$1
    Here are some of the links where I found answers:
    Webmaster World question about what is +FollowSymLinks
    Webmaster World question about when to use +FollowSymLinks
    Great article about what FollowSymLinks is... I gotta read this a few more times.


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
  •