1

I am new to .htaccess

I have created many links which open up pages based on a search result. The link addresses are, each link has a different prid such as 3110, 3111, 3222

http://mywebsite.com/prid-3110/1500-Sq-Ft-Residential-Plot-for-Sale-In-Arya-Shine-City-Irba-Ranchi-For-Rs-9.75-Lakh

I want this link to point to (ignore everything after the second slash)

 http://mywebsite.com/prid-3110/

My Current .htaccess rule is

RewriteRule ^prid-([0-9]+)$ views/propertyview.php?property_id=$1

The correct answer is working below

And add this the following so everything else like CSS, Images work because your browser will know from where to start looking for files.

<head> <base href="../"> </head>

1 Answers1

0

You can use:

RewriteRule ^prid-(\d+)(?:/|$) views/propertyview.php?property_id=$1 [NC,L]

With (?:/|$) you avoid prid-3110blabla, but you can use only:

RewriteRule ^prid-(\d+) views/propertyview.php?property_id=$1 [NC,L]

without this test.

Croises
  • 18,570
  • 4
  • 30
  • 47
  • thank you please give some explanation so a newbee can understand what is going on thanks –  Sep 24 '17 at 01:04
  • Yes, you can read: https://stackoverflow.com/questions/20563772/reference-mod-rewrite-url-rewriting-and-pretty-links-explained and https://en.wikipedia.org/wiki/Regular_expression – Croises Sep 24 '17 at 11:21