Note that there are some explanatory texts on larger screens.

plurals
  1. PORedirecting an absolute path in a .htaccess file
    primarykey
    data
    text
    <p>I have this site, where the URL's for the pages previously was something like:</p> <ul> <li><a href="http://www.thesite.com/page1" rel="nofollow">http://www.thesite.com/page1</a></li> <li><a href="http://www.thesite.com/page2" rel="nofollow">http://www.thesite.com/page2</a></li> <li><a href="http://www.thesite.com/page3" rel="nofollow">http://www.thesite.com/page3</a></li> </ul> <p>Please note, that there's no extension on any of these URL's even though that they were .php-files. It was a Wordpress-site that was in the root of the domain. The wordpress-site has now been moved into a folder, but I would like to setup a redirect from all the previous URL's to the new URL's (for SEO reasons). </p> <p>So far I found a temporary solution that is far from perfect. What I did was that I put this in the .htaccess-file (to remove the PHP-extensions):</p> <pre><code> # Turn on the rewrite engine RewriteEngine on # If the request doesn't end in .php (Case insensitive) continue processing rules RewriteCond %{REQUEST_URI} !\.php$ [NC] # If the request doesn't end in a slash continue processing the rules RewriteCond %{REQUEST_URI} [^/]$ # Rewrite the request with a .php extension. L means this is the 'Last' rule RewriteRule ^(.*)$ $1.php [L] </code></pre> <p>And then I've created the different files called the same as the previously URL's (with the .php-extension, which then is removed due to my .htaccess-file). In the top of each file, I have inserted a </p> <pre><code> &lt;?php header('Location: THE_NEW_URL'); ?&gt; </code></pre> <p>It works, but it's ugly as Betty! Recently, I encountered an error due to this temporary, stupid fix to my problem. I tried to setup a new page in the root of the folder (called test.php). This test.php-file has a stylesheet, that it links to the following way (pretty standard, I assume):</p> <pre><code> &lt;link href="css/style.css" rel="stylesheet" type="text/css" /&gt; </code></pre> <p>But the test.php-file can't find this stylesheet (and yes, I'm sure I uploaded it correctly). If I go to the source file and click it, then I can see that it tries to access </p> <pre><code> css/style.css.php </code></pre> <p>You don't have to be Einstein to know, that it's my .htaccess-file that has been raised amongst wolfs. But what should I do? Are there a way to make my .htaccess-file, so I can do something along the lines of:</p> <pre><code> Redirect from SPECIFIC_URL to A_NEW_SPECIFIC_URL </code></pre> <p>Where it doesn't screw up all URL's on my domain. I like have extensions on my files. I just need a fix for these 15 old URL's that has now been moved (that didn't have extensions).</p> <p>I suck at .htaccess-files and can't find any tutorials anywhere. It sucks! I don't know how to get better at it. I keep implementing solutions that I don't understand!?!</p>
    singulars
    1. This table or related slice is empty.
    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.
    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