Note that there are some explanatory texts on larger screens.

plurals
  1. POmod_rewrite slash snafu
    primarykey
    data
    text
    <p>So I know this question has been asked 20 other times and 20 different ways but after all of my researching I still can't seem to figure this out. My setup works great until I type in a URL with a trailing slash and then I get 404 errors. For example, when I type in the URL <code>mydomain.com/first</code> and hit enter, it works fine. When I type in <code>mydomain.com/first/</code> and hit enter, it works fine then too. But then, if I type in <code>mydomain.com/second</code> it sends me to <code>mydomain.com/first/second</code> and throws a 404 error.</p> <p>Here is my entire htaccess page:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^([a-zA-Z0-9_\-]+)/?$ index.php?url=$1 [NC,L] &lt;/IfModule&gt; </code></pre> <p>My index page:</p> <pre><code>&lt;?php define('ROOT_DIR', dirname(__FILE__) . '/'); // Define the root directory for use in includes require_once (ROOT_DIR . 'library/bootstrap.php'); $url = strtolower($_GET['url']); include(ROOT_DIR . 'views/headerView.php'); switch($url) { case "first": include(ROOT_DIR . 'views/firstPageView.php'); break; case "second": include(ROOT_DIR . 'views/secondPageView.php'); break; default: include(ROOT_DIR . 'views/homeView.php'); } include 'views/footerView.php'; ?&gt; </code></pre> <p>And the default homeView template:</p> <pre><code>&lt;p&gt;This is the home page.&lt;/p&gt; &lt;p&gt;To the first page. &lt;a href="first"&gt;First Page&lt;/a&gt;&lt;/p&gt; &lt;p&gt;To the second page. &lt;a href="second"&gt;Second Page&lt;/a&gt;&lt;/p&gt; </code></pre> <p>I would think that since the slash is optional and not part of the back reference, that the slash would be left off the URL after the page load but in my above example, its clearly not. Any advice would be most appreciated. Thank you</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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