Questions about PHP pseudo-static

Source: Internet
Author: User
PHP pseudo-static problems! My. htaccess is written as follows: Why $ index. php? Action = $1 & amp; id = $2 & PHP pseudo-static question!
Write my. htaccess as follows:


RewriteEngine on
RewriteRule (%a-za-z%}1,%}-(%0-9%}1,%}.html $ index. php? Action = $1 & id = $2


Program code:


Echo 'your Action is: '. $ _ GET ['action'];

Echo"
";

Echo 'Your ID is: '. $ _ GET ['id'];

?>

Enter:
Localhost/page-18.html

However, the following error is reported:

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, admin @ localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.


How can this problem be solved?



------ Solution --------------------
RewriteRule (%a-za-z%}1,%}-(%0-9%}1,%}.html $ index. php? Action = $1 & id = $2
There should be spaces before index. php
------ Solution --------------------
Why,
RewriteRule needs to have the original url and the transferred url. you don't have any space. apache cannot tell you clearly, so you have to go crazy 500.
------ Solution --------------------
. Htaccess is the function of apache and cannot take effect without modifying. conf. However, it is enabled by default in most cases.

If you are asking if you can implement url analysis and routing in php, Print_r your $ _ SERVER, which contains several variables:
Complete url. you can write code analysis and execute different codes.

Some open-source software have corresponding implementations. for details, refer

Discussion

Can this function be implemented without modifying Apache?

------ Solution --------------------
Discussion

Can this function be implemented without modifying Apache?

Recommended solution for my abnormal network:The server encountered an internal error () that prevented it from fulfilling this request., http://www.myexception.cn/java-web/317.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.