Vithya
Vithya

Reputation: 21

Rewrite base rule- php

Internal URL: example.com/abc/xyz/rule.php?price=1&pass=2
External URL: example.com/abc/xyz/rule/1/2

But the css, js files are not coming into effect in the external URL. My .htaccess file:

RewriteEngine On
RewriteBase /example.com/abc/
RewriteRule ^rule/([0-9]+)/([0-9]+)/?$ rule.php?price=$1&pass=$2

Upvotes: 0

Views: 1214

Answers (1)

Gumbo
Gumbo

Reputation: 655319

The “problem” is that relative URLs are resolved by the client and not by the server. And the base URL, the relative URLs are resolved from, is the URL of the current document. And in your case the base URL (path) is /abc/xyz/rule/1/2 and not /abc/xyz/rule.php?price=1&pass=2.

Now you have several ways to solve this:

  • Use relative URLs that are correctly resolvable from the actual base URL /abc/xyz/rule/1/2
  • Use absolute URLs that are independent from the base URL
  • Alter the base URL using HTML’s BASE element

Upvotes: 1

Related Questions