dreamwest
Members-
Posts
1,223 -
Joined
-
Last visited
Never
Everything posted by dreamwest
-
No. Because your fake urls wont exist news/category/id-title will have to be real eg: news/category/id-title/index.php OK clear your htaccess file and add just this: Options +FollowSymlinks RewriteEngine on RewriteRule ^news/(.*)/(.*) index.php?type=news&category=$1&id=$2 [L,QSA] Your url will be : site.com/news/cat/ or site.com/news/cat/3 or site.com/news/anothercat/ or site.com/news/catanothercat/5 Let me know how it went
-
htaccess rules Regex Character Definitions for htaccess2 [ ^ ] # the # instructs the server to ignore the line. used for including comments. each line of comments requires it’s own #. when including comments, it is good practice to use only letters, numbers, dashes, and underscores. this practice will help eliminate/avoid potential server parsing errors. [F] Forbidden: instructs the server to return a 403 Forbidden to the client. [L] Last rule: instructs the server to stop rewriting after the preceding directive is processed. [N] Next: instructs Apache to rerun the rewrite rule until all rewriting directives have been achieved. [G] Gone: instructs the server to deliver Gone (no longer exists) status message. [P] Proxy: instructs server to handle requests by mod_proxy [C] Chain: instructs server to chain the current rule with the previous rule. [R] Redirect: instructs Apache to issue a redirect, causing the browser to request the rewritten/modified URL. [NC] No Case: defines any associated argument as case-insensitive. i.e., "NC" = "No Case". [PT] Pass Through: instructs mod_rewrite to pass the rewritten URL back to Apache for further processing. [OR] Or: specifies a logical "or" that ties two expressions together such that either one proving true will cause the associated rule to be applied. [NE] No Escape: instructs the server to parse output without escaping characters. [NS] No Subrequest: instructs the server to skip the directive if internal sub-request. [QSA] Append Query String: directs server to add the query string to the end of the expression (URL). [s=x] Skip: instructs the server to skip the next "x" number of rules if a match is detected. [E=variable:value] Environmental Variable: instructs the server to set the environmental variable "variable" to "value". [T=MIME-type] Mime Type: declares the mime type of the target resource. [] specifies a character class, in which any character within the brackets will be a match. e.g., [xyz] will match either an x, y, or z. []+ character class in which any combination of items within the brackets will be a match. e.g., [xyz]+ will match any number of x’s, y’s, z’s, or any combination of these characters. [^] specifies not within a character class. e.g., [^xyz] will match any character that is neither x, y, nor z. [a-z] a dash (-) between two characters within a character class ([]) denotes the range of characters between them. e.g., [a-zA-Z] matches all lowercase and uppercase letters from a to z. a{n} specifies an exact number, n, of the preceding character. e.g., x{3} matches exactly three x’s. a{n,} specifies n or more of the preceding character. e.g., x{3,} matches three or more x’s. a{n,m} specifies a range of numbers, between n and m, of the preceding character. e.g., x{3,7} matches three, four, five, six, or seven x’s. () used to group characters together, thereby considering them as a single unit. e.g., (perishable)?press will match press, with or without the perishable prefix. ^ denotes the beginning of a regex (regex = regular expression) test string. i.e., begin argument with the proceeding character. $ denotes the end of a regex (regex = regular expression) test string. i.e., end argument with the previous character. ? declares as optional the preceding character. e.g., monzas? will match monza or monzas, while mon(za)? will match either mon or monza. i.e., x? matches zero or one of x. ! declares negation. e.g., “!string” matches everything except “string”. . a dot (or period) indicates any single arbitrary character. - instructs “not to” rewrite the URL, as in “...domain.com.* - [F]”. + matches one or more of the preceding character. e.g., G+ matches one or more G’s, while "+" will match one or more characters of any kind. * matches zero or more of the preceding character. e.g., use “.*” as a wildcard. | declares a logical “or” operator. for example, (x|y) matches x or y. \ escapes special characters ( ^ $ ! . * | ). e.g., use “\.” to indicate/escape a literal dot. \. indicates a literal dot (escaped). /* zero or more slashes. .* zero or more arbitrary characters. ^$ defines an empty string. ^.*$ the standard pattern for matching everything. [^/.] defines one character that is neither a slash nor a dot. [^/.]+ defines any number of characters which contains neither slash nor dot. http:// this is a literal statement — in this case, the literal character string, “http://”. ^domain.* defines a string that begins with the term “domain”, which then may be proceeded by any number of any characters. ^domain\.com$ defines the exact string “domain.com”. -d tests if string is an existing directory -f tests if string is an existing file -s tests if file in test string has a non-zero value
-
They know more regex than i do and theyre using write rules - which i havnt gotten into yet Anyway the example i gave you is sound, you most likely problem is RewriteRule ^news/$ index.php?type=news [L,QSA] its taking all urls with news - change to RewriteRule ^news/ index.php?type=news [L,QSA], so your url is http://www.site.com/news/. Then add your other rule in This site is a classic example of rewrite http://www.findtail.com
-
Your right the rules are combining Try this #default news page -> http://www.site.com/news/ RewriteRule ^news/$ index.php?type=news [L,QSA] #working news section -> http://www.site.com/news/cat1/ OR http://www.site.com/news/cat1/3 RewriteRule ^news/(.*?)/([0-9]+)-(.*?)$ index.php?type=news&category=$1&id=$2 [L,QSA] If that doesnt work youll have to make the root unique #default news page -> http://www.site.com/news/ RewriteRule ^news/$ index.php?type=news [L,QSA] #working news section -> http://www.site.com/newscat/cat1/ OR http://www.site.com/newscat/cat1/3 RewriteRule ^newscat/(.*?)/([0-9]+)-(.*?)$ index.php?type=news&category=$1&id=$2 [L,QSA]
-
Common problem. You need to have a root comand on all you includes "/", that includes pictures too so in css just add /style.css instead of style.css
-
Yes. You can also simplify it resulting in a lot less work and lines #default news page -> http://www.site.com/news/ RewriteRule ^news/$ index.php?type=news #working news section -> http://www.site.com/news/cat1/ OR http://www.site.com/news/cat1/3 RewriteRule ^news/(.*?)/([0-9]+)-(.*?)$ index.php?type=news&category=$1&id=$2
-
In somefolder directory add this htaccess RewriteRule ^fakefolder/fakefile somefolder/somefile.php Simple
-
No that how rewrite works...its a fake url - dosnt exist You dont need a forward slash for the fake url RewriteEngine on RewriteRule ^ (.*)/room thermometers.php?products=$1 So your link will be <a href="/thermometers/room">
-
You have 3 dynamic rules with no write stops [L,QSA] so its gonna keep writing into your next rule You can still have it like you had but use anchors RewriteRule ^(.*?)$ index.php?type=$1 RewriteRule ^Anchor_name_(.*?)/(.*?) index.php?type=$1&category=$2 RewriteRule ^Another_anchor_/(.*?)/([0-9]+)-(.*?)$ index.php?type=$1&category=$2&articleid=$3 If you dont have write rules you cant have 3 dynamic roots RewriteRule ^ DYNAMIC ROOT --> (.*?)$ index.php?type=$1 RewriteRule ^ DYNAMIC ROOT --> (.*?)/(.*?) index.php?type=$1&category=$2 RewriteRule ^ DYNAMIC ROOT --> (.*?)/(.*?)/([0-9]+)-(.*?)$ index.php?type=$1&category=$2&articleid=$3
-
Use it in htaccess Header unset ETag FileETag None I have a share host but my pages load faster than a dedicated server. Etags wont speed it up much, theres 15 or so things you can do to cut 95% of loading time from your pages Some are : flush(); //will "flush" your tables and divs first and load content later strip //remove all whitespace Cache //see my post in above in htacces tricks sticky
-
.htaccess file mod rerwrite rule coming up with 404 page not found
dreamwest replied to agallo's topic in Apache HTTP Server
You dont need a root command in htaccess unless its a directory ErrorDocument 404 error404.php Or ErrorDocument 404 /errors/error404.php -
Set your default type RewriteRule ^(.*)$ index.php?type=default_name Depending on your interface you need a anchor RewriteRule ^News/(.*?) index.php?type=News&category=$1 Otherwise it can be dynamic based on the hyperlink, but this can cause issues with your article id rule RewriteRule ^(.*?)/(.*?) index.php?type=$1&category=$2 This needs an anchor if you use the above dynamic rule RewriteRule ^News/(.*?)/([0-9]+)-(.*?)$ index.php?type=News&category=$1&articleid=$2
-
RewriteCond %{HTTP_HOST} ^site.com [NC] RewriteRule (.*)$ http://www.site.com/$1 [L,R=301] Redirects http://site.com to http://www.site.com
-
I find it entertaining when ppl try to hack my site, for me its chess Theres lots of things you can do, first use http referer to check what address the bot is coming from $ip_address = $_SERVER['REMOTE_ADDR']; $referer = $_SERVER['HTTP_REFERER']; This will give you some info of whats happening, store this in a database so you can review the most evil ips. Then use one of the many tricks to play with them, send them to a hackers site to get there server infected or wherever you feel like
-
You have to add the path to your css, if your css is style.css, then the browser will loook for the css here: edithotel/54321/style.css all you have to do is add a root command to you include <link rel="stylesheet" href="/style.css" type="text/css" />
-
RewriteRule ^test/(.*) http://www.site.com
-
User-agent: * Disallow:
-
how can i add document.write to a radio button value?? <input id="country" name="meta" value="<script>document.write(geoip_country_code());</script>" type="radio">
-
How can i store document.write as a variable This outputs the country code "AU" <script language="JavaScript">document.write(geoip_country_code());</script> Now i need to use it in a php script <? $code = ;//document.write output here ?>
-
I have alot of ifelse clauses in my search script which adds up to 20KB. I wondering if i put these into an external file as functions or include the ifelse script if(somethin == true){ function stuff(one,two); } or a ifelse include include_once('ifelse.php'); Would this increase my loading time and wich would be faster?
-
Thanks. Go it to works
-
I cant figure out whats going on with this, the out put is: 2 loops http://site.com http://site2.com http://site3.com http://site.com 1 http://site2.com 2 http://site3.com 3 4 http://site.com http://site2.com http://site3.com http://site.com 1 http://site2.com 2 http://site3.com 3 4 The code i used is: $links = "http://site.com<br> http://site2.com<br> http://site3.com<br>"; $linksArray = explode('<br>', $links); $counter = 1; $result = ''; foreach ($linksArray as $l) { $links .= $l . '<br> ' . $counter . ' '; $counter++; } echo $links; For 2 loops the out put should be: http://site.com<br> 1 http://site2.com<br> 2
-
I have a group of links but need to add a number next to each $links = "http://site.com<br> http://site2.com<br> http://site3.com<br>"; //etc..up until 25 links I thought of using strreplace and explode but they will both replace - for example the <br> with the same number, but i need to count how many <br> tags there are in the variable and add a niumber next to each So basically i need the output to be: $links = "http://site.com<br> 1 http://site2.com<br> 2 http://site3.com<br> 3"; //etc..up until 25 links
-
Excellent Thanks!