Jump to content


Photo

RewriteRule like Twitter

twitter rewriterule htaccess

Best Answer Terminator1995, 16 March 2014 - 08:22 AM

I solved my problem :happy-04:

RewriteCond %{THE_REQUEST} ^.*\.php.*$
RewriteRule ^(.*)$ ErrorDocument/404.html [L]
Go to the full post


  • Please log in to reply
5 replies to this topic

#1 Terminator1995

Terminator1995

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 13 March 2014 - 09:26 AM

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



#2 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,025 posts
  • LocationWA

Posted 13 March 2014 - 12:48 PM

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.

#3 Terminator1995

Terminator1995

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 14 March 2014 - 09:51 AM

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



#4 requinix

requinix

    Transforming Moderator

  • Moderators
  • 6,025 posts
  • LocationWA

Posted 14 March 2014 - 01:09 PM

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?

#5 Terminator1995

Terminator1995

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 15 March 2014 - 10:58 AM

With :

ErrorDocument 404 /ErrorDocument/404.html

OK - can i make it like that

RewriteRule ^(.*\.php)$  /ErrorDocument/404.html [L,R=404]


#6 Terminator1995

Terminator1995

    Newbie

  • New Members
  • Pip
  • 4 posts

Posted 16 March 2014 - 08:22 AM   Best Answer

I solved my problem :happy-04:

RewriteCond %{THE_REQUEST} ^.*\.php.*$
RewriteRule ^(.*)$ ErrorDocument/404.html [L]





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com