简体   繁体   中英

about url rewriting and js extension with php

I'm asking about the ability if I can use .js file as .PHP extension for example :

<script src="exampl.php">/script>

and if this method causes any problem ?

the second question is, if I make a url rewriting for making the extension to .js, how can I block the direct accès to example.php, and allow it when the visitor go to example. j's

I'm so sorry for my bad English, please help me and thank's to everyone how will participate :)

Assuming you are using Apache as a web server it would be better to create a rewrite rule: Create or edit .htaccess and add: RewriteRule ^example.js$ example.php [L]

For the second part you could check $SERVER_['HTTP_REFERER'] or use CSFR token method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM