-1

I am trying to make pretty url in PHP. URL is working but CSS and JS is not working.

File path is: example.com/store.php?brand=brand_name

Desired url : http://example.com/store/brand-name

Code:

RewriteEngine On
RewriteRule ^store/(.*)/?$ store.php?brand=$1    [NC,L]    # Handle product requests
geekhere
  • 99
  • 1
  • 2
  • 12

1 Answers1

1

Nothing to do with .htaccess. Actually your pages are not getting CSS and JS as paths are not correct, that's why issue is coming.

You need to set constant variable like BASE_URL for your domain that you will include for all your CSS and JS like below:

base_url.php

<?php
define('BASE_URL', 'http://example.com');
?>

index.php:

<?php
    include('base_url.php');
?>
<!DOCTYPE html>
<html>
  <head>
    <!-- // -->
    <link rel="stylesheet" href="<?php echo BASE_URL; ?>/css/styles.css" />
 </head>
 <body>
 <!-- // -->
 </body>
</html>

You can also add this constant variable if you have connection.php or any other common file that includes in all the pages where you are using CSS and JS.

Amit Gupta
  • 2,771
  • 2
  • 17
  • 31