KSC
KSC

Reputation: 1

How to redirect orginal url if partial url or short url come

I want to redirect url if partial url get like stackoverflow manage or other sites. Is that possible in php.

eg. https://stackoverflow.com/questions/21150608/htaccess-redirect-partial

It automatic convert to orignal url

eg. https://stackoverflow.com/questions/21150608/htaccess-redirect-partial-url-pattern

Upvotes: 0

Views: 180

Answers (2)

rosengrenen
rosengrenen

Reputation: 771

The important part of the url is the id, e.g.

yourdomain.com/questions/{id}/{slug}

You would have to check the id against a database and check if the slug provided matches the slug related to the requested id, if not, redirect to the complete url.

Upvotes: 1

PraveenKumar
PraveenKumar

Reputation: 1861

You can do that by using .htacess

# Permanent URL redirect 
Redirect 301 /questions/21150608/htaccess-redirect-partial /questions/21150608/htaccess-redirect-partial-url-pattern

Upvotes: 0

Related Questions