Jump to content

Am I missing something simple with my htaccess?


Go to solution Solved by denno020,

Recommended Posts

I've been using htaccess in my web projects for a little while now, both at home and at work. I'm currently working on a website for a friend, which is a wordpress one, and I'm trying to set up my htaccess in the root of my website which will handle old links, and forward people on the the new location (they previously had presta shop, which uses a different link structure).

 

Anyway, I've got my public folder on my host, which has my htaccess, an index.php file, and a wordpress folder, which has all of the wordpress stuff.

The plan was to capture links that weren't already going to a wordpress subdirectory, pass them to the index.php file, and then that will work out where the user should be redirected to.

 

Sounds simple enough, but for whatever reason, it's just not working and I can't for the life of me figure out why.

 

The following is my htaccess file:


# Use PHP5.4 Single php.ini as default
AddHandler application/x-httpd-php54s .php
RewriteEngine On
 
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^((?!wordpress).)*$   index.php?url=$0 [QSA,L]

So as you can see, it's very simple. The first few lines before RewriteEngine are specific for my host.

 

Anyway, this works perfectly on my local server (wamp), however running it on my live server, I continually get "404:File Not Found". The index file is in the exact same location as the htaccess file, so there isn't any problem with that.

I've also tried putting junk into my htaccess, to see if it's actually being used, and it is. If I put "some junk" (literally that string) into my htaccess just before the RewriteEngine on directive, I get this message:

[an error occurred while processing this directive]

So I know my htaccess is being read..

 

Can anyone see something that I'm missing?

 

Thanks,

Denno

  • Solution

So I figured out what the problem was, in case anyone was wondering.

 

I had a temporary URL, as I'm moving the website to a different hosting company, and it turns out that when I was reading the http_host in my php file, it was only pulling the ip address in, it wasn't also pulling in the my username which corresponded to my folder on their server.

 

Anyway, that probably doesn't explain it very well, but it's all fixed now, so that's the main thing.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.