php - Redirecting from one page to another page on my website causes 404 error after using .htaccess file


Currently I'm working on a php blog.Where I have used .htaccess file to get clean url,here is the code.

RewriteEngine On
RewriteCond %{HTTPS} !=off
RewriteCond %{HTTP_HOST} ^mywebsitename\.com$
RewriteRule (.*)$1 [R=301,L]
RewriteRule ^([0-9]+)/([a-zA-Z0-9_-]+)?$ post.php?post_id=$1&title=$2 [L]
RewriteRule ^(.+)/(admin|css|fonts|ico|include|js|images)/(.*)$ $2/$3 [L] 

I got this code online.As I'm new to php and this htaccess thing,that's why I don't have much idea about it.

URL Before adding .htaccess file was: [][1]

And,URL after adding .htaccess file:

So rewriterule gave me the url that I want.But it has cause error in redirection of the page.Before using .htaccess file whenever i clicked on home button after visiting following url: then URL redirected successfully to home page,that is: page.

But now after using .htaccess file after visiting the same url it is redirecting like this: http://www/

And now it is firing 404 page not found error.Because technically there is no such page present under 12 directory on server.

So after visiting the following link: I want it to redirect properly as it was redirecting the pages before adding the .htaccess file.

Please guys help me out. Thanks in advance.




Is the link your actual url. Is mywebsitename the your domain name? I think you should replace it with the actual domain name. It might just be a placeholder text

People are also looking for solutions to the problem: php - Pass query string to same method in controller in codeigniter


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.