Terminator1995 Posted March 13, 2014 Share Posted March 13, 2014 Hi, first I'm sorry if I posting this in wrong forum - and sorry for my bad english. I want to make RewriteRules like Twitter - So that the files are displayed as Virtual folders, but if you add the file extensions (.php) he shouldn't view this file! .htaccess edit: AddDefaultCharset UTF-8 Options +FollowSymlinks Options -Indexes Options -ExecCGI <FilesMatch "^\." > deny from all </FilesMatch> RewriteEngine on RewriteBase / RewriteCond %{SERVER_PORT} !=443 RewriteRule ^(.*)$ https://www.abc.com/ [R=301,L] RewriteRule ^profil/$ profil.php?ID=$1 [NC,L] RewriteRule ^([^.]+)/([^.]+)/$ $2.php?ID=1 [NC,L] Can anyone help me?? Best regards Termi Quote Link to comment https://forums.phpfreaks.com/topic/286938-rewriterule-like-twitter/ Share on other sites More sharing options...
requinix Posted March 13, 2014 Share Posted March 13, 2014 When talking about URL rewriting you need to say precisely what URLs are you looking to be "virtual folders" and how should they map to PHP scripts. The "profil" (are you sure you don't want "profile"?) one is missing the part where it captures the ID in the URL. Presumably that's a number? RewriteRule ^profil/(\d+)$ profil.php?ID=$1 [L]The second one is very generic. What is it supposed to be used for? It should be more specific than simply "anything slash anything". Also, avoid [NC] when possible. URLs should be case-sensitive, or at the very least redirect to a particular cased version. Quote Link to comment https://forums.phpfreaks.com/topic/286938-rewriterule-like-twitter/#findComment-1472479 Share on other sites More sharing options...
Terminator1995 Posted March 14, 2014 Author Share Posted March 14, 2014 1. ) Yes the name "Profil" is correct, it's the german name of profile ;-) 2. ) Yes the ID is a number. 3. ) OK i updated my htaccess, with your hints (Thanks for that)! But my question was (if you add the file extensions (.php) he shouldn't view this file!), have you an answer for that. Best regards Quote Link to comment https://forums.phpfreaks.com/topic/286938-rewriterule-like-twitter/#findComment-1472596 Share on other sites More sharing options...
requinix Posted March 14, 2014 Share Posted March 14, 2014 But my question was (if you add the file extensions (.php) he shouldn't view this file!), have you an answer for that.How do you handle 404 pages? Quote Link to comment https://forums.phpfreaks.com/topic/286938-rewriterule-like-twitter/#findComment-1472612 Share on other sites More sharing options...
Terminator1995 Posted March 15, 2014 Author Share Posted March 15, 2014 With : ErrorDocument 404 /ErrorDocument/404.html OK - can i make it like that RewriteRule ^(.*\.php)$ /ErrorDocument/404.html [L,R=404] Quote Link to comment https://forums.phpfreaks.com/topic/286938-rewriterule-like-twitter/#findComment-1472715 Share on other sites More sharing options...
Solution Terminator1995 Posted March 16, 2014 Author Solution Share Posted March 16, 2014 I solved my problem RewriteCond %{THE_REQUEST} ^.*\.php.*$ RewriteRule ^(.*)$ ErrorDocument/404.html [L] Quote Link to comment https://forums.phpfreaks.com/topic/286938-rewriterule-like-twitter/#findComment-1472771 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.