How we can convert dynamic url into static url? plz provide
code.

Answer Posted / udit rawat

Add an .htaccess file(if using apache)

# Turn on URL rewriting
RewriteEngine On

RewriteBase /

# Allow any files or directories that exist to be displayed
directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]
This redirects all urls to index.php. index.php will be some
sort of front controller that loads scripts based on the url

So in your example:

localhost/mywebsite/mypage

Is This Answer Correct ?    3 Yes 4 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Where do I run php code?

531


What is csrf token in php?

550


What is difference between array_merge and array_combine in php?

509


How to copy a file?

565


What is the difference between static and dynamic websites?

510






What is php beginner?

504


What is php destruct?

530


What is difference between get and post in php?

611


What is php constructor?

543


Do you know what's the difference between __sleep and __wakeup?

532


What are some new features introduced in php7?

8380


What is the use of the function htmlentities?

627


How we can declare variable in php?

514


Is nan in php?

531


How variables are passed through arguments?

556