Jump to content
php.lv forumi

htaccess un php


keiG

Recommended Posts

Sveiki! Vēršos šeit, jo htaccess tik labi nepārzinu.

ideja ir apvienot url normālformu ar seo formu

tātad šeit ir esošais htaccess 

RewriteEngine on
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?lang=$1&page=$2&id=$3&id2=$4 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?lang=$1&page=$2&id=$3 [L]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?lang=$1&page=$2 [L]
RewriteRule ^([^/\.]+)/?$ index.php?lang=$1 [L]

Vēlamā rezultāta piemērs:


Ar esošo htaccess seo formā viss kas sākās ar ? netiek ņemts vērā.

Esmu redzējis vairākām lapām šādu lietu, bet pašam uzrakstīt neizdevās. Nepieciešams priekš google kampaņu statistikas.

Netā meklēju, bet neko konkrētu neatradu.

Ir kādas idejas?

Link to comment
Share on other sites

Nu ko tomēr atradu!

RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?lang=$1&page=$2&id=$3&method=$4 [L,QSA]
RewriteRule ^([^/\.]+)/([^/\.]+)/([^/\.]+)/?$ index.php?lang=$1&page=$2&id=$3 [L,QSA]
RewriteRule ^([^/\.]+)/([^/\.]+)/?$ index.php?lang=$1&page=$2 [L,QSA]
RewriteRule ^([^/\.]+)/?$ index.php?lang=$1 [L,QSA]

Tad varbūt kādam noderēs :)

Link to comment
Share on other sites

Un ar miljons dažādiem linkiem un sublinkiem aizdirsīsi lieki htaccess.

 

Man personīgi ir šāds: 

# Rewrite current-style URLs of the form 'index.php?q=x'.
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
Link to comment
Share on other sites

Es arī izmantoju drupal ģenerēto ar full over-ride:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

Pārējo jau mans scripts ar db ierakstiem apstrādā.

Link to comment
Share on other sites

Es pagaidām rūtējot iztieku bez db pieprasījumiem, bet man arī .htaccess ir vienkāršs:

RewriteEngine on
RewriteCond %{REQUEST_URI} !^/images/
RewriteCond %{REQUEST_URI} !^/css/
RewriteCond %{REQUEST_URI} !^/js/
RewriteCond %{REQUEST_URI} !robots.txt
RewriteCond %{SCRIPT_FILENAME} !index.php
RewriteRule .* ./index.php [L]

Nesaprotu tos cilvēkus, kuri rewraito request path uz GET parametru. Priekš kam, ja var apstrādāt reālo REQUEST_URI?

Edited by jurchiks
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...