0

At present the webpage accepts get params like this https:// MY SITE/details.php?id=AlphaNumericKeys
Which I want to make it look like https://TripTale.in /details/someTexts/AlphaNumericKeys

Contents of my .htaccess file

Options All -Indexes
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?tripTale\.in)$ [NC]
RewriteRule .? https://%1%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? /404.php [L]

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^details/(.*)$ details.php?q=$1 [QSA]

RewriteRule ^details/(\d+)/([\w-]+)$    details.php?id=$1&title=$2

RewriteRule ^details/([0-9]+)/([A-Za-z0-9-\+]+)/?$ /details.php?id=$1&title=$2

All the above tried code does not works and shows error 404.
However the below code works but makes all the images file as blank.

Options All -Indexes
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.(([a-z0-9_]+\.)?tripTale\.in)$ [NC]
RewriteRule .? https://%1%{REQUEST_URI} [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .? /404.php [L]

RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule .? /404.php

RewriteRule ^([A-Za-z0-9]+)/([A-Za-z0-9]+) details.php?id=$1&title=$2 [QSA]
Sourav
  • 17,065
  • 35
  • 101
  • 159
  • What's the relevance of `someTexts` in the desired URL? It looks like that is simply discarded, unless you are parsing the URL-path later, or passing this in the URL param as well? (But if you are parsing the URL-path in PHP then you don't need to pass the `id` URL param.) It looks like you have tried to implement this, what problem are you having specifically? (You are using a `q` param in your rule, rather than `id`? And this has a different value to what you are expecting, but enough to debug this I would have thought.) – MrWhite May 15 '23 at 18:49
  • To confirm, you have already changed your internal links to the desired canonical URL, ie. you are linking to URLs of the form `/details/someTexts/AlphaNumericKeys`? – MrWhite May 15 '23 at 18:49
  • @MrWhite someTexts is just for SEO friendliness, the main part is ID. Yes I'm trying to access the path through /details/someTexts/AlphaNumericKeys and the details.php file is in the www directory. – Sourav May 16 '23 at 16:17

0 Answers0