Hi Everyone,
I have copied a .htaccess file from one website and I am trying to use the same htaccess file on a different website.

here is the copy of the htaccess file I have copied from one site to another...

<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteRule ^(\d+)/([^/]+)/?$ index.php?uiid=$1&title=$2 [L]
</IfModule>

both websites have the same structure as
/domname.com/dir1/dir2/shopping-cart/index.php
The htaccess file successfully rewrites the above url into the below url
/domname.com/dir0/dir1/shopping-cart/302/this-is-a-second-test-item

But for some reason, the htaccess file doesnt work & I get the error
The requested URL /domname.com/dir1/dir2/shopping-cart/index.php was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Can someone point me in the right direction with a fix to why this would not be working,
But, it works perfectly on the website I copied it from...

Recommended Answers

All 3 Replies

Member Avatar for LastMitch

@DaveyMoyes

Can someone point me in the right direction with a fix to why this would not be working,

Is dir0 and dir1 are URL keys? Then you need to create a new Mod for them. If those are not URL keys but a folder then you need to relink from the old one to the new one.

To rewrite as in URL Keys it should look something like this (it's not tested):

//Rewrite 1
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^([^/]+)/([^/]+).html /index.php?uiid=$1&title=$2 [NC,R]

//Rewrite 2
RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^(.*)/(.*)\.html /index.php?uiid=$1&title=$2 [R=301,L]

Relink should be something like this (it's not tested either):

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^dir0\.html$ "http\:\/\/www\.domname\.com\/dir0\.php" [R=301,L]

RewriteCond %{HTTP_HOST} ^.*$
RewriteRule ^dir1\.html$ "http\:\/\/www\.domname\.com\/dir1\.php" [R=301,L]

Hi, the first thing to check out when YOU COPY IN CODES in htaccess file and the site breaks error 500 - is to make sure there are no whitespaces in the line end. Heads up on that.

What editor do you use? I never had an issue with whitespace when I was using Apache.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.