Note that there are some explanatory texts on larger screens.

plurals
  1. POApache Mod Rewrite for Pretty URLs isn't working
    primarykey
    data
    text
    <p>I'm trying to figure out how to do an apache <code>mod_rewrite</code> to remap <code>$_GET</code>.</p> <p><strong>What I'm trying to accomplish:</strong></p> <p>Currently, to get to the page one would have to go to </p> <p><code>http://www.domain.com/index.php?URL=pages/the-page.php</code></p> <p><strong>I would like this to work in 2 ways:</strong></p> <p>If someone goes to <code>domain.com/the-page</code>, it takes them to the above but keeps it looking like this. Secondly, if someone goes to the <code>http://www.domain.com/index.php?URL=pages/the-page.php</code>, it will still show as <code>domain.com/the-page</code>, keeping the URL short and clean.</p> <p><strong>Most Recently Tried Code</strong></p> <pre><code>Options +FollowSymlinks RewriteEngine on RewriteCond %{REQUEST_URI} ^/index\.php$ RewriteCond %{QUERY_STRING} URL=pages/([a-z0-9-_]+)\.php$ RewriteRule ^(.*) /%1 </code></pre> <p>I'm pretty sure I setup everything right in the apache <code>httpd.conf</code>. I'm using XAMPP to test locally, restarted apache on changes, still nothing. Where am I going wrong?</p> <p><em><strong>I would prefer to handle this in .htaccess</em></strong></p> <p>I am using XAMPP localhost and trying on live server.</p> <p><strong>Log File:</strong></p> <p><code> 127.0.0.1 - - [05/Apr/2013:16:50:43 --0400] [localhost/sid#2f3140][rid#3b14068/initial] (3) [perdir C:/xampp/htdocs/cdi/] strip per-dir prefix: C:/xampp/htdocs/cdi/index.php -&gt; index.php</code></p> <p><code>127.0.0.1 - - [05/Apr/2013:16:50:43 --0400] [localhost/sid#2f3140][rid#3b14068/initial] (3) [perdir C:/xampp/htdocs/cdi/] applying pattern '^(.*)' to uri 'index.php'</code></p> <p><code>127.0.0.1 - - [05/Apr/2013:16:50:43 --0400] [localhost/sid#2f3140][rid#3b14068/initial] (1) [perdir C:/xampp/htdocs/cdi/] pass through C:/xampp/htdocs/cdi/index.php</code></p> <p><strong>Updated log with Olaf's script <em>(last rule commented out)</em></strong></p> <p><code>127.0.0.1 - - [05/Apr/2013:20:02:24 --0400] [localhost/sid#2e3140][rid#3b14090/initial] (3) [perdir C:/xampp/htdocs/cdi/] strip per-dir prefix: C:/xampp/htdocs/cdi/index.php -&gt; index.php</code></p> <p><code>127.0.0.1 - - [05/Apr/2013:20:02:24 --0400] [localhost/sid#2e3140][rid#3b14090/initial] (3) [perdir C:/xampp/htdocs/cdi/] applying pattern '^' to uri 'index.php'</code></p> <p><code>127.0.0.1 - - [05/Apr/2013:20:02:24 --0400] [localhost/sid#2e3140][rid#3b14090/initial] (3) [perdir C:/xampp/htdocs/cdi/] strip per-dir prefix: C:/xampp/htdocs/cdi/index.php -&gt; index.php</code></p> <p><code>127.0.0.1 - - [05/Apr/2013:20:02:24 --0400] [localhost/sid#2e3140][rid#3b14090/initial] (3) [perdir C:/xampp/htdocs/cdi/] applying pattern '^index\.php$' to uri 'index.php'</code></p> <p><code>127.0.0.1 - - [05/Apr/2013:20:02:24 --0400] [localhost/sid#2e3140][rid#3b14090/initial] (2) [perdir C:/xampp/htdocs/cdi/] rewrite 'index.php' -&gt; '/newhome?'</code></p> <p><code>127.0.0.1 - - [05/Apr/2013:20:02:24 --0400] [localhost/sid#2e3140][rid#3b14090/initial] (3) split uri=/newhome? -&gt; uri=/newhome, args=&lt;none&gt;</code></p> <p><code>127.0.0.1 - - [05/Apr/2013:20:02:24 --0400] [localhost/sid#2e3140][rid#3b14090/initial] (2) [perdir C:/xampp/htdocs/cdi/] explicitly forcing redirect with http://localhost/newhome</code> <strong><em>&lt;--this one seems to be causing the issue</em></strong></p> <p><code>127.0.0.1 - - [05/Apr/2013:20:02:24 --0400] [localhost/sid#2e3140][rid#3b14090/initial] (1) [perdir C:/xampp/htdocs/cdi/] escaping http://localhost/newhome for redirect</code></p> <p><code>127.0.0.1 - - [05/Apr/2013:20:02:24 --0400] [localhost/sid#2e3140][rid#3b14090/initial] (1) [perdir C:/xampp/htdocs/cdi/] redirect to http://localhost/newhome [REDIRECT/302]</code></p> <p>Thank you everyone that is helping. I've spent 2 days trying to get this to work!!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload