1

Hi I'm having a problem with my redirection rule. Currently i redirect all page to index.php and the routes will check the correct controller.

  1. Everything works fine if the request is localhost/project/home
  2. But if if change the request to localhost/project/home/ all links are not working.

This is the folder architecture:

enter image description here

This what it looks like on localhost/project/home:

enter image description here

This is what it looks like on localhost/project/home/:

enter image description here

This is my .htacess:

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.*+)$ index.php?path=$1 [QSA,L]

Thanks

8
  • This line: localhost/project/home/ means: localhost/project/home/index.php/ Commented Feb 28, 2018 at 4:41
  • How would i get it to redirect to root index.php ?@SalimIbrogimov Commented Feb 28, 2018 at 4:43
  • I think the problem is that you can't load .css and .js files, right? Commented Feb 28, 2018 at 4:45
  • Yes @SalimIbrogimov. I tried excluding it on .htaccess but its not working. Still new to .htaccess Commented Feb 28, 2018 at 4:46
  • please, check the url of .css and .js files! Commented Feb 28, 2018 at 4:46

1 Answer 1

1

Seems your css files are not loading because it is not getting the correct path. Better if you can use baseUrl in your css links as follows.

<link rel="stylesheet" type="text/css" href="http://localhost/project/css/style.css">
Sign up to request clarification or add additional context in comments.

2 Comments

Is there any solution that can use relative urls?
There can be some solutions for it. But It is better to build a function to get the baseUrl (localhost/project) from your system and append the balance part ('css/style.css'). Thats the way, we use css, javascript links in most popular PHP frameworks such as Zend, Laravel and etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.